Closed paulbors closed 4 years ago
My hunch is that the target/process-test-coverage folder is being recreated each time a test class is executed.
If if run one test class at a time, I do see the class folder being added to the target/process-test-coverage folder one by one. When I run them all at once... only the report folder from the last class that run exists.
Hi @paulbors,
how do you execute your tests? From your IDE or with maven? Are all tests successfully?
Running mvn clean test
should give you the desired result.
All test pass just fine (I just wrote them). It happens on both the IDE (IntelliJ IDEA Ultimate 2018.1) and Maven on localhost Windows 10 as well as Linux via Jenkins by cleaning up the working space and performing a fresh checkout.
On localhost via the IDE, I had to run one test class at a time in order to get the test coverage folder added one at a time per test class. If I run All the tests via maven or in my IJ as JUnit run config... Only the output of the last folder is present.
Where in the code do you guys create/write the test class coverage report? I would like to glimpse over that logic.
Keep in mind my test config shuts down the workflow engine and starts a new one per each test class I run.
Hi @paulbors ,
Maybe the root cause is in your project setup/Class hirachy?
I've tried it with this example: https://github.com/camunda-consulting/simple-junit-test. Two processes, two test classes, all coverage is collected in the target/process-test-coverage folder after running mvn clean test
.
It seems to be a problem if the rule is declared in the super class... See #43
Hi @paulbors
I examined your use case. Here is what I found out.
There are two modes how you can use the rule:
@Rule
so it gets initialized and generates method coverage only.@ClassRule
and @Rule
and you will get class coverage along with method coverage.In the second case, the rule is static and is initialized once (actually on the first run) which means it will get the class name from the first inherited class and will generate one class report for this. In the same time, it will collect all methods from all classes inheriting from the same class in that report. So I could reproduce your issue. This is not really a bug, but more the issue of static rule. My advice is not to use static class rule to a super class if you want to get report per class - it is by the way just fine to do so if you want to separate your tests in classes but interested in one aggregated report.
I'll close the issue for now.
I noticed that if I run a single class I get the expected coverage report just fine, odly enough is always the last test class that run. This happens on both Windows and Linux via IntelliJ and Maven.
activity.cfg.xml in test resources set to:
Test class signature:
Camunda v7.10 community jUnit v4.12 SpringBoot v2.1.3.RELEASE Java v8 camunda-bpm-process-test-coverage v0.3.2
Please advice!