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 186277 - REGRESSION: Focus is not given to the test results if ANT output has not been opened
Summary: REGRESSION: Focus is not given to the test results if ANT output has not been...
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: JUnit (show other bugs)
Version: 6.x
Hardware: PC Linux
: P2 normal (vote)
Assignee: Andrey Yamkovoy
URL:
Keywords:
: 186275 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-05-18 07:13 UTC by Alexei Mokeev
Modified: 2010-08-19 03:24 UTC (History)
4 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
A patch for the bug 186277 (4.32 KB, patch)
2010-05-19 01:30 UTC, Victor Vasilyev
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexei Mokeev 2010-05-18 07:13:09 UTC
If you execute tests by "Test" popup menu on the project node and you also have at least one failed tests then test results window is not shown by default and focus is given to Output tab.

Steps:

- Create couple tests one of them failing
- Execute them by invoking 'Test' on project node

You will see that Output tab is shown instead of test results.
Comment 1 Alexei Mokeev 2010-05-18 07:27:46 UTC
*** Bug 186275 has been marked as a duplicate of this bug. ***
Comment 2 Alexei Mokeev 2010-05-18 09:02:26 UTC
When we do have failed tests the corresponding ant build is set as failed.
Seems that during 6.9 the behavior of output window has changed and now it always activates the tab with ANT output in case of failure.

Seems that the most logical fix would be to set ignore.failing.tests property to true when running tests from IDE to prevent failing of ANT build.
Comment 3 Victor Vasilyev 2010-05-19 01:30:49 UTC
Created attachment 99167 [details]
A patch for the bug 186277

Proposed patch fixes this bug with minimal changes and risks.
Nevertheless, it also changes the class org.apache.tools.ant.module.run.TargetExecutor in the Ant module (o.apache.tools.ant.module).
Hence, the peer review of the Ant module owner is required additionally to the process specified here http://wiki.netbeans.org/NB69HighResistance
Comment 4 Victor Vasilyev 2010-05-19 01:52:15 UTC
FYI Here is specification:
http://ui.netbeans.org/docs/ui/progress_indication/progress_indication_spec.html#5_behaviour_of_tasks

Unfortunately, the specification doesn't take into account this case, i.e. when two "output" windows are shown. 

BTW In this case, an appropriate "output" window is the "Test Results", and usual "Output" window is only secondary view of results.
Comment 5 Alexei Mokeev 2010-05-19 04:35:50 UTC
Hi Jesse, could you please take a look at  Victor's patch  ?
It's touching o.apache.tools.ant.module/src/org/apache/tools/ant/module/run/TargetExecutor.java
Comment 6 Alexei Mokeev 2010-05-19 10:54:20 UTC
Seems that the change in behavior is caused by the fix from 2010-04-02 of issue 
162159 [1]:
'displayed' variable is not set to true by the call of interestingOutputCallback.run(), that's why the output is activated at the very end of ant build.


[1]http://hg.netbeans.org/main/rev/66582d893086
Comment 7 Jesse Glick 2010-05-19 13:55:35 UTC
Is this really a P1 bug? The stack trace from the failed test continues to be displayed, and the Test window is still easily available. (If you even want it at all; see bug #118772.) Also note that you can disable Always Show Output if you prefer to see Ant output unconditionally for builds.

The root bug may actually be something I have noticed in the past few months but did not yet get to filing: stack traces are displayed in Ant output at the end of the test suite rather than at the end of the test case. Therefore the OW is focused after the Test Results window gets notification of the error. This may be a problem in <junit> rather than the IDE. Might be possible to work around this in the junit module by focusing this window at the end of a test suite, but I'm not sure about the details.

(In reply to comment #2)
> Seems that during 6.9 the behavior of output window has changed and now it
> always activates the tab with Ant output in case of failure.

This was the traditional behavior, that was accidentally broken for a release or two.

> Seems that the most logical fix would be to set ignore.failing.tests property
> to true when running tests from IDE to prevent failing of Ant build.

I would agree with this approach. You can verify that it would work by adding ignore.failing.tests=true to private.properties.

The test targets should by default fail if tests fail, by the principle of least surprise and under the assumption that exit code is being used to control further actions; but any container which interprets test results directly (a CI server like Hudson, an IDE like NetBeans) should set this flag. Note that the Hudson integration already does so when creating jobs for NB projects.

(In reply to comment #3)
> Proposed patch [...] changes the class
> org.apache.tools.ant.module.run.TargetExecutor

This seems an unnecessary hack in light of comment #2.
Comment 8 Alexei Mokeev 2010-05-19 16:10:29 UTC
(In reply to comment #7)

>Might be possible to work
>around this in the junit module by focusing this window at the end of a test
>suite, but I'm not sure about the details.

This is for sure the best solution, unfortunately it's unclear on how to implement it other than by patch from comment #3 as 'build finished' happens after test suite completion.

So ignore.failing.tests=true seems to be a straightforward way, I would only put it into Tools->Options->Miscellaneous->Ant->Properties instead of private.properties. In this case it would work for all Ant based projects (Maven projects are not affected as output is shown by default).
Comment 9 Jesse Glick 2010-05-19 16:23:06 UTC
(In reply to comment #8)
> So ignore.failing.tests=true seems to be a straightforward way, I would only
> put it into Tools->Options->Miscellaneous->Ant->Properties

Not a good idea. This could affect any Ant build, even of a freeform project which depends on failed tests preventing a deploy! Also it assumes that every project type uses this exact property name.

Rather, j2seproject and similar project types should pass this property to test-related targets in their ActionProvider impl, and JavaRunnerImpl should be made to not record a build failure in case of test failures (if not already the case).
Comment 10 Jesse Glick 2010-05-19 16:34:08 UTC
I'm afraid I'm in the middle of a laptop switch so it is impossible to prepare a tested patch or anything, but the general idea:

1. java.source.ant/src/org/netbeans/modules/java/source/ant/resources/junit-snippet.xml and java.source.ant/src/org/netbeans/modules/java/source/ant/resources/junit-debug-snippet.xml already look OK, just needs to be tested.

2. java.j2seproject/src/org/netbeans/modules/java/j2seproject/resources/build-impl.xsl uses ignore.failing.tests, so java.j2seproject/src/org/netbeans/modules/java/j2seproject/J2SEActionProvider.java should modify getTargetNames for COMMAND_*TEST* to call p.setProperty("ignore.failing.tests", "true").

3. Something similar to #2 needs to happen at least for web.project and j2ee.*project.
Comment 11 Alexei Mokeev 2010-05-20 12:05:06 UTC
Thanks Jesse. With this idea the changes in action providers will touch all Java projects, Web projects and J2EE projects. The change is low-risk but I would not do it right prior to RC1. 
 *Likely* the proper solution should be implemented which should transfer the focus to test results window after the build completion, likely together with
issue #118772

So I suggest to downgrade this to P2, relnote, and do not fix for 6.9.
Motivation:
- No data loss and user can easily switch tabs to access test results window.
- Workaround exist: add ignore.failing.tests into private.properties or ant properties.

Marian, are you OK with downgrading this to P2 (filed after cut-off) ?
Comment 12 Marian Mirilovic 2010-05-20 12:56:04 UTC
> Marian, are you OK with downgrading this to P2 (filed after cut-off) ?
no problem, I am marking as 69patch candidate, so we'll fix it into patch once we will know it will be released.
Comment 13 Alexei Mokeev 2010-05-20 16:00:15 UTC
Thanks. Set target to the .Next.
Comment 14 rbalada 2010-06-22 07:49:39 UTC
Please report on progress, especially if you can make it into 6.9.1, if not please consider removing 6.9.1_CANDIDATE keyword.

Thanks,
-R
Comment 15 Alexei Mokeev 2010-06-22 08:28:01 UTC
Removing 6.9.1_CANDIDATE keyword. Not critical in terms of functionality.
Comment 16 Andrey Yamkovoy 2010-08-18 10:56:51 UTC
Fixed in the main (changeset: 0f4915ddb3df).
Comment 17 Quality Engineering 2010-08-19 03:24:31 UTC
Integrated into 'main-golden', will be available in build *201008190001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/0f4915ddb3df
User: Andrey Yamkovoy <kaktus@netbeans.org>
Log: Fix for #186277 - REGRESSION: Focus is not given to the test results if ANT output has not been opened