-
Notifications
You must be signed in to change notification settings - Fork 9
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
No Unit Test Coverage or Mutation Coverage reported for Robolectric based Unit Tests #80
Comments
With the Worker API: https://docs.gradle.org/nightly/userguide/worker_api.html#changing_the_isolation_mode Also for aggregate reporting.
Could you share a project with a minimal reproducible example demonstrating this issue? |
Hey @koral-- The class NotCoveredLogic has the RobolectricTestrunner, which, if you comment out, then returns 100% mutation coverage, the same as CorrectlyCoveredLogic class |
Thanks, will check it. |
Hey there @koral-- checking in with you, did you get a chance to check this issue over? |
Hi, sorry for the delay but not yet. |
It seems that robolectric perform some actions that cause pitest to not work correctly. I've reported this issue to upstream: hcoles/pitest#1065 |
Thanks for the effort to date, hoping this can get some attention upstream |
I've taken a look at this and the issue looks to be that Roboelectric now loads the classes from a classloader other than the context one (this is a change from the last time I had to prod pitest to get the two working together some years ago). This is issue is similar to one I fixed recently for QuarkusTest, but roboelectric appears to keep a pool of classloaders somewhere, which complicates things for pitest considerably. I have some horrible hacking locally that looks to fix the issue for the simple case demonstrated in https://github.com/im-not-josh/PlayGround. I'm concernted it may not work with something more complex that uses roboelectric for real. I don't do Android dev, so have no idea what that looks like. If someone could create a slightly more complex project that makes more realistic use of roboeletric I'll see if the fix looks viable. If there's anyway this can be made self contained (ie not rely on an android sdk being already configured on a machine) that would be helpful. At the moment I can't see how I could add an integration test to the build for this. |
Wow awesome job! I'm so happy to have progress on this so fast. Thank you! |
@im-not-josh The roboelectric test in the repo doesn't seem to actually do anything - it runs green with the standard junit runner. I presume a more representative test would mock out part of the android sdk in some way? If you could update it so it does even a minimal amount of androidy stuff, that would be helpful. I'll push a branch with my changes once I've tidied up some of the hacking. |
@im-not-josh The changes for this are in the branch https://github.com/hcoles/pitest/tree/feature/roboelectric If you'd like to try it out
should take about 3:30, and produce pitest-1.0.0-SNAPSHOT into your local .m2 repo. It would still be helpful if you could update https://github.com/im-not-josh/PlayGround to include some slightly more realistic roboelectric tests. My main concern is that the bytecode transformation pitest is doing will clash with any transformation performed by roboelectric (which I think will not be performing any in the current example). |
@im-not-josh Have you had chance to update the repo or try out the branch? I'd prefer not to merge the changes into pitest until I have some confidence they fix the issue. |
Hey @hcoles I updated the versions of pitest ( to match current prod releases, not your robo changes branch) also but it seems like that has caused some more issues. The tests I added fail before mutation, stating the string resources cannot be found. I will also some more robolectric based tests and android junit based tests with some more examples for you. |
More tests added, some test based on Room DB. Normally in robolectric tests, we add this into our gradle config: it allows resources like strings to be included in tests builds. This is set in the example app so the tests pass when running outside of mutation. Seems like that same property should also be applied in the mutation tests. That should resolve the no string resource found error. For now, those tests could be commented out to run to completion. |
Added yet more tests, more android sdk based this time. Bitmap stuff which is always fun |
Last update for the day today, I finally managed to get your snapshot working locally. |
@im-not-josh Thanks for this. Unfortunately I won't be able to look into for a few weeks, but the updated example will be very helpful. |
I'm also facing this issue, so I'd be interested in any updates :-) |
Hello,
I am seeing an issue where, the Unit Test coverage and Mutation test coverage reported for each unit test using RobolectricTestRunner is 0.
Pitest runs to completion, there is no error. If i remove RobolectricTestRunner (and disable tests that need it) coverage is reported as expected.
I am using the latest version of pitest and robolectric, 1.7.3 and 4.7.3.
Setting excludeMockableAndroidJar = true or excludeMockableAndroidJar = false doesnt seem to make a difference here either.
Any ideas?
The text was updated successfully, but these errors were encountered: