-
Notifications
You must be signed in to change notification settings - Fork 353
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
Pitest reports a subset of tests failing, when all the tests are identical #1266
Comments
Hi Andrew, Thanks for the report. I've just taken a very quick look at this. The test is failing with
I had to add a catch block to the test to get this, which isn't great. I think some changes are needed to the junit5 plugin to get errors like this to bubble out to the log as you'd expect. The reason that one test runs green and the other runs red seems to be that ProjectBuilder only attempts to inject the synthetic class the first time it is run. Some internal state somewhere is changed and the call works the 2nd time. As to why the tests pass without pitest ... they don't. The test class isn't picked up by Presumably the tests would fail in the same way when run under normal junit if whatever changes required to pick the test class up are made. |
Ah, thanks for looking, that's frustrating -- I tried to slim down my test case but slimmed it down too far and trusted that my tests were still fine and Gradle was skipping them because they were up-to-date, sorry. I've pushed a new commit, along with an extra (failing) test so the results show up in the Actions output. I see three tests run and one fail when running check, but three tests run and two of them fail when running pitest. The commit is here: https://github.com/andrewaylett/gradle-plugins/tree/21c9bd92225b03ba33254ed4cd5272b640069e29, hopefully I've got it right this time? Although having said that, from the error you found I wonder if this is another case of #1164? |
Yes, it seems likely that gradle is using the module path to run the tests while pitest is still using classpath. I think I will finely have to look at modulepath support. I had hoped to be able to put it off until java 8 was out of common usage, but a lot of pitest users still seem to be tied to it. For the moment you can work around the issue for this project with
I've raised pitest/pitest-junit5-plugin#102 To cover the logging issue. |
Thanks -- I can confirm that adding |
Example project: https://github.com/andrewaylett/gradle-plugins/tree/pitest-fails-green
To check out the cut-down test case:
git clone https://github.com/andrewaylett/gradle-plugins cd gradle-plugins git switch pitest-fails-green
To run the unit tests outside Pitest:
To run Pitest:
What you should see
The unit tests pass when run as plain unit tests. There are two tests, the content is identical, with no assertions, so one expects them to pass or fail together.
When run under pitest, the first of the tests to be executed will fail, subsequent test will pass.
What I expected to see
Both tests pass under pitest, the same as outside of pitest
Notes
This is cut down from a larger test suite -- tests that don't interact with
ProjectBuilder.build()
pass, the first test that callsbuild()
fails, subsequent tests callingbuild()
all pass.I'm running on an AMD64 Mac, JDK is Temurin 17.
I've tried to work out why the test is failing, but I've not been able to work out what the actual failure is.
The text was updated successfully, but these errors were encountered: