Skip to content
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

Testsuite fatal error output not shown #89

Closed
molexx opened this issue Oct 17, 2018 · 8 comments
Closed

Testsuite fatal error output not shown #89

molexx opened this issue Oct 17, 2018 · 8 comments

Comments

@molexx
Copy link

molexx commented Oct 17, 2018

With a config like this:

testlogger {
	showStandardStreams true
	
	showPassedStandardStreams false
	showSkippedStandardStreams false
	showFailedStandardStreams true
}

if the test suite run itself fails - i.e. not 'a test does not pass' but the test execution failing due to something else e.g. an @Sql setup script with an error in it - gradle fails and stderr says:

> Task :test FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':test'.

but there's no indication as to what the problem was. If I run again with --info I can see that the stdout explains the problem in detail, but that disables the above testlogger filters.

Could testlogger notice the suite failure and show the output please?

@radarsh
Copy link
Owner

radarsh commented Oct 17, 2018

Hmm, that's not a nice behaviour from the plugin. Let me see what I can do. Thanks for reporting this.

@radarsh
Copy link
Owner

radarsh commented Oct 29, 2018

Hi @molexx, would you be able to provide an sscce for this so that I can provide an accurate fix? Thanks.

@molexx
Copy link
Author

molexx commented Oct 30, 2018

I've investigated what's happening: System.exit(5) is being called.

I guess this is somewhat unexpected behaviour for JUnit tests but I have seen several StackOverflow posts suggest that as a way to abort the rest of the test suite so as to not waste when a fatal error has happened.

Would it be right for gradle-test-logger-plugin to catch the VM's non-zero exit code, treat that as a failed test and show the output?

Thanks.

@radarsh
Copy link
Owner

radarsh commented Oct 30, 2018

Interesting. Would be good to find out what Gradle would do without the test logger plugin applied and with a configuration like this:

test {
    testLogging {
        showStandardStreams = true
    }
}

@radarsh
Copy link
Owner

radarsh commented Nov 21, 2018

Hi @molexx, could you share a bit more detail about this please? Where is System.exit(5) being called from? Is it in a setup method? Also what happens when you try this? Thanks. This info will be quite invaluable.

@molexx
Copy link
Author

molexx commented Nov 21, 2018

Behaviour is the same for @Test and @Before methods which do some output before calling System.exit(5):

Without gradle-test-logger applied and without the above test{ testLogging { showStandardStreams=true}} the stdout/stderr messages are not shown.

Without gradle-test-logger applied but with the above test{ testLogging { showStandardStreams=true}} the stdout/stderr messages are shown.

With gradle-test-logger applied the test is reported as SKIPPED (in yellow), then the expected behaviour happens: if testLogger's showStandardStreams and showSkippedStandardStreams are true the messages are seen.
I don't think it should be detected as SKIPPED though, as the test suite's VM aborted without the test completing and with status 5 (which gradle notices and reports as in the first post).

@BeforeClass methods are similar without gradle-test-logger - with test{ testLogging { showStandardStreams=true}} the outputs show.

But with gradle-test-logger applied, even with all options set to true:

testlogger {
	showStandardStreams true
	
	showPassedStandardStreams true
	showSkippedStandardStreams true
	showFailedStandardStreams true
}

the System.out and System.err in the @BeforeClass method are not seen.

@radarsh
Copy link
Owner

radarsh commented Mar 12, 2019

I don't think it should be detected as SKIPPED though, as the test suite's VM aborted without the test completing and with status 5 (which gradle notices and reports as in the first post).

Unfortunately, there is nothing the plugin can do about this as this is Gradle's internal behaviour. I have fixed the missing system out issue though. It was a genuine bug, thanks for reporting it and the detailed analysis 👍

@molexx
Copy link
Author

molexx commented Mar 13, 2019

Ah ok seeing the messages is the main thing, thanks! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants