New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JUnit test cannot write to the Output window #126

Closed
km-works opened this Issue Mar 25, 2014 · 10 comments

Comments

Projects
None yet
3 participants
@ghost

ghost commented Mar 25, 2014

I use NetBeans 8.0RC1 and G4NB 1.3.0
I realized that, if you have any System.out.println() in your JUnit test cases the output doesn't make it neither to the Output window nor to the right pane of the Test Results window. It simply disapears.
Furthermore test statistics output from JUnit like
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0,05 sec
is missing from the Output window too.

@kelemen

This comment has been minimized.

Owner

kelemen commented Mar 26, 2014

stdout and stderr are aggregated in JUnit's output xml for all tests in the same class. So the best I could probably do is to display the same output for each test (in the same class) in the right pane.

The output window only contains what Gradle writes to the stdout (and stderr). Probably the best you could do for this is to "prinln" yourself this info in the Gradle script. As is now, it is not possible to print this info reliably when a test task has been executed from the NB plugin (for example, when running a task which depends on a test task). The test results window just guesses that if you run the test command (and similar) then the test xmls should have been created.

@ghost

This comment has been minimized.

ghost commented Mar 27, 2014

stdout and stderr are aggregated in JUnit's output xml for all tests in the same class. 

Yes, I know :)

So the best I could probably do is to display the same output for each test (in the same class) 
in the right pane.

Would be very helpfull. And at the same occasion, couldn't you just append this test result text to the Output window too, as it is done in Ant and Maven project types?

The output window only contains what Gradle writes to the stdout (and stderr). 
Probably the best you could do for this is to "prinln" yourself this info in the Gradle script. 

That's probably not feasible, because the output may depend on the computation done in the test method.

@kelemen

This comment has been minimized.

Owner

kelemen commented Mar 27, 2014

... couldn't you just append this test result text to the Output window too ...

It is technically possible when the test results window is displayed but not in general. That is, if you for example run a task which depends on test, then it isn't.

That's probably not feasible, because the output may depend on the computation done in the test method.

I meant, you parsing the output xml after the test task completes. This should be done in a finalizedBy task because this has to be done even if the test task fails.

I'll most likely add the output to the test results window for the next version but I'm not sure about printing extra info to the end of the output window.

@fwelland

This comment has been minimized.

fwelland commented Apr 3, 2014

FWIW -- I just tripped over this issue too. I would love to see output in the right-hand portion of the Test Results Tab -- I don't care if STDERR and STDOUT are mixed (but maybe some visual clue like a color differnce would be great).

Our primary use case for this is Run Focused Method or Test File. Our team uses these features often during the DEV cycle.

Related -- I added

test.testLogging.showStandardStreams = true

To top of my build.gradle and at least on the output window I get the output.

@kelemen

This comment has been minimized.

Owner

kelemen commented Apr 3, 2014

This is a simple request, so you can most likely see this in the next version. Though, probably color coding is not possible because as far as I can see, the API only allows me to set a single string. So I'll probably go with: stderr first then stdout (clearly separatig them, like with a bunch of stars in a line).

@ghost

This comment has been minimized.

ghost commented Apr 4, 2014

Thank you for

test.testLogging.showStandardStreams = true

That works for the output window!

On Thu, Apr 3, 2014 at 8:55 PM, Fred Welland notifications@github.comwrote:

FWIW -- I just tripped over this issue too. I would love to see output in
the right-hand portion of the Test Results Tab -- I don't care if STDERR
and STDOUT are mixed (but maybe some visual clue like a color differnce
would be great).

Our primary use case for this is Run Focused Method or Test File. Our team
uses these features often during the DEV cycle.

Related -- I added

test.testLogging.showStandardStreams = true

To top of my build.gradle and at least on the output window I get the
output.


Reply to this email directly or view it on GitHubhttps://github.com//issues/126#issuecomment-39490507
.

@kelemen

This comment has been minimized.

Owner

kelemen commented Apr 5, 2014

This should be fixed in master. Stderr and stdout are printed in the right pane of the test results window. Stderr is printed before stdout and they are color coded.

If you plan to build the plugin from the sources using NB 8.0, please note that tests must be skipped for now because there seems to be a bug in NB when running unit tests.

@kelemen kelemen closed this Apr 5, 2014

@kelemen

This comment has been minimized.

Owner

kelemen commented Apr 5, 2014

As it turned out, the problem is not the version of NB you build with but the JDK. So, tests won't run with JDK 8 for now.

@ghost

This comment has been minimized.

ghost commented Apr 5, 2014

Great, thank you!

On Sat, Apr 5, 2014 at 2:55 AM, Attila Kelemen notifications@github.comwrote:

As it turned out, the problem is not the version of NB you build with but
the JDK. So, tests won't run with JDK 8 for now.


Reply to this email directly or view it on GitHubhttps://github.com//issues/126#issuecomment-39624559
.

@fwelland

This comment has been minimized.

fwelland commented Apr 9, 2014

Hi,

Just tested this (1.3.0.0.1) and it works nicely.

Thanks for all your work!

BTW:
Product Version: NetBeans IDE 8.0 (Build 201403101706)
Java: 1.7.0_45; Java HotSpot(TM) 64-Bit Server VM 24.45-b08
Runtime: Java(TM) SE Runtime Environment 1.7.0_45-b18
System: Linux version 3.13.7-200.fc20.x86_64 running on amd64; UTF-8; en_US (nb)
User directory: /home/fwelland/.netbeans/8.0
Cache directory: /home/fwelland/.cache/netbeans/8.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment