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

PowerMockito @PrepareForTest disables JaCoCo #49

Open
mmert1988 opened this issue Jul 11, 2018 · 5 comments
Open

PowerMockito @PrepareForTest disables JaCoCo #49

mmert1988 opened this issue Jul 11, 2018 · 5 comments

Comments

@mmert1988
Copy link

mmert1988 commented Jul 11, 2018

When using PowerMock in the unit tests, the classes declared with @PrepareForTest don't get coverage info due to following error:

[ant:jacocoReport] Classes in bundle 'app' do no match with execution data. For report generation the same class files must be used as at runtime.
[ant:jacocoReport] Execution data for class com/example/android/ExampleClassA does not match.
[ant:jacocoReport] Execution data for class com/example/android/ExampleClassB does not match.

After a small research I've found out that it's a known issue of jacoco regarding javassist/javaagent:

powermock/powermock#422
jacoco/eclemma#15

But unfortunately, I wasn't able to make the fix of the issue, as suggested for maven by using the custom java agent of PowerMock library, to work for gradle, because I couldn't declare a jar file from dependencies (powermock-api-mockito2-1.7.4.jar) as a custom java agent in gradle, as done in this workaround:

http://stevendick.github.io/blog/2012/02/12/jacoco-and-gradle-part-2/

It failed, since the java plugin is conflicting with the android plugin.

@sachinlohith
Copy link

I found a workaround to this issue. Basically, you'll need to create a new Test-class for the class prepared for test by Powermock. This will reset any changes made by PowerMock to the class.

@johnbrown8976
Copy link

I found a workaround to this issue. Basically, you'll need to create a new Test-class for the class prepared for test by Powermock. This will reset any changes made by PowerMock to the class.

Could you provide an example with working code?

Thanks,
John

@ghost
Copy link

ghost commented Jan 25, 2020

I found a workaround to this issue. Basically, you'll need to create a new Test-class for the class prepared for test by Powermock. This will reset any changes made by PowerMock to the class.

any working code ?

@allefsousa
Copy link

Could you provide an example with working code?

@Poojashivaswamy
Copy link

Could anyone please provide workaround for this?

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

5 participants