This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 70749 - JUnit Results window does not display for tests run from freeform projects
Summary: JUnit Results window does not display for tests run from freeform projects
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: JUnit (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Marian Petras
URL:
Keywords:
Depends on: 71124
Blocks:
  Show dependency tree
 
Reported: 2005-12-22 20:17 UTC by Jesse Glick
Modified: 2006-10-23 16:40 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2005-12-22 20:17:18 UTC
Noticed in a 5.1 dev build but probably applies to 5.0 as well.

Build and install ant/freeform/samples. Use e.g. the "Ant-Based Anagram Game"
template to make a project, and run tests for the Anagram Library project. The
tests run and output is displayed in the Output Window; but the JUnit Results
window never shows anything.

I suspect that the culprit is various unwarranted assumptions in the junit
module about the project running the tests. I see several places in the code
that seem to hardcode details of particular project types like j2seproject. In
particular, JUnitAntLogger.detectSessionType and
JUnitOutputReader.PROP_RESULTS_DIRS are clearly inappropriate for freeform projects.
Comment 1 Marian Petras 2006-01-05 08:52:07 UTC
Confirmed, accepted.
Comment 2 Marian Petras 2006-01-05 14:45:26 UTC
Fixed (in the trunk).

In JUnitAntLogger.detectSessionType, I just added "run-tests" to the list of
recognized targets. I could not find any better (not too complicated) solutuion.

As for determination of a results directory, I removed the PROP_RESULTS_DIRS
list and the <junit> task is analyzed instead - see the diff of JUnitOutputReader.


Modified files:
    junit/src/org/netbeans/modules/junit/output/:
                                           JUnitAntLogger.java   (1.13)
                                           JUnitOutputReader.java   (1.16)

Diffs:
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/output/JUnitAntLogger.java?r1=1.12&r2=1.13&diff_format=u
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/output/JUnitOutputReader.java?r1=1.15&r2=1.16&diff_format=u
Comment 3 Jesse Glick 2006-01-05 18:13:00 UTC
JUnitOutputReader looks better. BTW

resultsDir = new File(event.getProperty("basedir"), resultsDir.getPath());

is probably not the safest way to write this - would recommend remembering the
actual result of event.evaluate(dirName), rather than relying on new
File(s).getPath().equals(s), which is probably true but might not be.

The change to JUnitAntLogger is not very comforting. "run-tests" just happens to
be the name I picked for these samples; may not correspond to what other
projects use.

Also the usage of AntSession.getOriginatingTargets() should be a warning sign.
This means that if you do something innocent-looking like write a simple
build.xml somewhere that has a target like "run-all-tests" that runs tests for a
couple of IDE-created projects in turn, you will not get anything in JUnit
Results for this whole Ant process! Whereas you would get results if you ran the
individual project's tests one at a time. Not very nice.

Perhaps you could get rid of the concept of "session type" altogether, and just
listen for either <junit> tasks being run, or matching <java> tasks (e.g. with
"junit.textui.TestRunner" as the class name). Would be some refactoring, and you
would lose the ability to show "Preparing tests..." immediately in JUnit
Results; "Running tests..." would appear after a delay during which the tests
were compiled. I don't think this would be so bad, especially when issue #63586
is implemented - at which time we would start displaying a regular progress
indicator for the running Ant build, and change Options > Ant > Always Show
Output to be off by default, so you are not distracted by normal successful test
compilation.
Comment 4 Marian Petras 2006-01-05 22:37:39 UTC
As regards "new File(s).getPath().equals(s)", I will fix it.

But I do not plan to make any complex changes at this stage of development of
this release.
Comment 5 Max Sauer 2006-01-06 13:58:36 UTC
Inside 200601051900, I still don't get test results inside JUnit Results window,
only in Output window for the above mentioned usecase.

[NB 5.1 200601051900, JDK 1.6.0 b65, solaris 10/sparc]
Comment 6 Max Sauer 2006-01-06 14:43:41 UTC
Looks like the JUnit test results window is properly displayed when using Test
project (Alt-F6) action, but not when running single tests via run file.
Comment 7 Marian Petras 2006-01-06 17:15:12 UTC
Yes, apparently I fixed it only partly. When the whole project is tested, the
test results window displays results as expected. When testing a single test, it
does not work.

I will integrate at least this partial fix and I will make a better fix later
(after release).
Comment 8 Marian Petras 2006-01-06 19:50:42 UTC
The partial fix was committed to branch "release50" (ported from the trunk).

Modified files:
    junit/src/org/netbeans/modules/junit/output/:
                                           JUnitAntLogger.java   (1.12.2.1)
                                           JUnitOutputReader.java   (1.13.2.3)

Diffs:
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/output/JUnitAntLogger.java?r1=1.12&r2=1.12.2.1&diff_format=u
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/output/JUnitOutputReader.java?r1=1.13.2.2.&r2=1.13.2.3&diff_format=u
Comment 9 Max Sauer 2006-01-09 09:44:33 UTC
I have verified the partial fix inside 5.0 RC1 build 200601082030.
Comment 10 Marian Petras 2006-05-26 20:53:15 UTC
This is due to the mechanism of recognizing "testing Ant targets". Test targets
are currently recognized by name.

It will be changed. Names of Ant targets will not be taken into account.
Comment 11 Marian Petras 2006-05-26 21:17:31 UTC
Fixed in the trunk.

The unreliable mechanism recognizing test targets by their names was replaced
with a new mechanism which recognizes test _tasks_ by their names and structure.

Modified files:
src/org/netbeans/modules/junit/output/JUnitOutputReader.java   (1.19)
src/org/netbeans/modules/junit/output/junit-test-results.settings   (1.2)
src/org/netbeans/modules/junit/output/TaskType.java   (1.1 - initial revision)
src/org/netbeans/modules/junit/output/junit-test-results.wstcref   (1.2)
src/org/netbeans/modules/junit/output/AntSessionInfo.java   (1.3)
src/org/netbeans/modules/junit/output/Manager.java   (1.10)
src/org/netbeans/modules/junit/output/JUnitAntLogger.java   (1.14)
nbproject/project.properties   (1.8)

Diffs:
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/output/JUnitOutputReader.java?r1=1.18&r2=1.19&diff_format=u
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/output/junit-test-results.settings?r1=1.1&r2=1.2&diff_format=u
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/output/TaskType.java?rev=1.1&content-type=text/vnd.viewcvs-markup
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/output/junit-test-results.wstcref?r1=1.1&r2=1.2&diff_format=u
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/output/AntSessionInfo.java?r1=1.2&r2=1.3&diff_format=u
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/output/Manager.java?r1=1.9&r2=1.10&diff_format=u
http://junit.netbeans.org/source/browse/junit/src/org/netbeans/modules/junit/output/JUnitAntLogger.java?r1=1.13&r2=1.14&diff_format=u
http://junit.netbeans.org/source/browse/junit/nbproject/project.properties?r1=1.7&r2=1.8&diff_format=u

The change fixes also the following bugs:
  bug #59883 - Floating window wars between JU output & all others windows
  bug #73397 - "Failed to prepare tests" - display better message
  bug #73933 - JUnit window pops up after running Ant 'test' target
  bug #76587 - JUnit results window often reopens itself