pitest / pitest-junit5-plugin

JUnit 5 test framework support for Pitest
Apache License 2.0
74 stars 26 forks source link

Mock method invocation expected 1 invocation, actual 2 invocations #59

Open MosheElisha opened 3 years ago

MosheElisha commented 3 years ago

After upgrading from pitest-junit5-plugin 0.10 to 0.11, a unit test started failing. The same problem occurs in 0.14 as well.

java.lang.AssertionError:
  Unexpected method
3:00:41 PM PIT >> INFO : MINION : call PrometheusScrapeEndpoint.scrape([]):
    PrometheusScrapeEndpoint.scrape(<any>): expected: 1, actual: 2

EasyMock expected that PrometheusScrapeEndpoint.scrape(<any>) will be invoked only once but it was invoked twice. When I execute maven with -DskipPitest, all tests pass successfully.

The following ZIP contains maven output with verbose=true for

mvn.pitest-junit5-plugin-0.10.out - pass mvn.pitest-junit5-plugin-0.11.out - fail mvn.pitest-junit5-plugin-0.14.out - fail

mvn-out.zip

pitest-maven = 1.6.2 junit-jupiter-api = 5.7.1

hcoles commented 3 years ago

If you can put together a minimal project that reproduces the issue, I can take a look.

MosheElisha commented 3 years ago

Thanks, @hcoles ! I'll try to create a minimal project.

MosheElisha commented 3 years ago

Hi @hcoles ,

I have created a small project that reproduces the issue. With pitest-junit5-plugin=0.10 the command mvn clean install works fine. With 0.11 and 0.14 the command fails on the basis of a failed test.

Failed to execute goal org.pitest:pitest-maven:1.6.2:mutationCoverage (default) on project pitest-junit5-plugin-issue-59: Execution default of goal org.pitest:pitest-maven:1.6.2:mutationCoverage failed: 1 tests did not pass without mutation when calculating line coverage. Mutation testing requires a green suite.

Can you please take a look?

pitest-junit5-plugin-issue-59.zip