Developer_3.x Tests - kitodo/kitodo-production GitHub Wiki

Mutation testing

To measure the quality of our tests, we are using the mutation testing framework Pitest.

Pitest runs your unit tests against automatically modified versions of your application code. When the application code changes, it should produce different results and cause the unit tests to fail. If a unit test does not fail in this situation, it may indicate an issue with the test suite.

To run a mutation test, you have to add the Pitest plugin to build/plugins in your moduls pom.xml.

<plugin>
    <groupId>org.pitest</groupId>
    <artifactId>pitest-maven</artifactId>
    <version>LATEST</version>
 </plugin>

By default Pitest will mutate all code in your project/module. You can limit which code is mutated and which tests are run using targetClasses and targetTests.

<plugin>
    <groupId>org.pitest</groupId>
    <artifactId>pitest-maven</artifactId>
    <version>LATEST</version>
    <configuration>
        <targetClasses>
            <param>com.your.package.root.want.to.mutate*</param>
        </targetClasses>
        <targetTests>
            <param>com.your.package.root*</param>
        </targetTests>
    </configuration>
</plugin>

The mutation test can be run directly from the commandline

mvn org.pitest:pitest-maven:mutationCoverage

This will output an html report to target/pit-reports/YYYYMMDDHHMI.

Selenium testing

Debugging

To debug a selenium the Selenium profile of Maven must be started in debug mode.

It may be necessary to make a mvn clean beforehand. However, this is not necessary if the command is called several times.

class

mvn install -Pselenium -D"it.test=**/TestST" -D"maven.failsafe.debug" verify

method

mvn install -Pselenium -D"it.test=**/TestST#testMethod" -D"maven.failsafe.debug" verify

After that the Maven Failsafe Plugin listen at port 5005 for the connection to your debugger.

[INFO] Listening for transport dt_socket at address: 5005

Once your debugger is connected, the execution will continue. Please do not forget to set the breakpoint beforehand. 😉

Execution single Selenium based tests

Precondition: Running Selenium based tests through maven (mvn verify -Pselenium) are working.

Running a single Selenium based test class can be executed in this way

mvn verify -Pselenium -pl Kitodo -Dit.test=ListingQueryParameterST 

The command above will run the ListingQueryParameterST Selenium based test class as an integration test (-Dit.test) inside the Kitodo module (-pl) with an activated Selenium profile (-Pselenium) in the Maven verify phase.

Running a single test from a whole Selenium based class is even possible

mvn verify -Pselenium -pl Kitodo -Dit.test=ListingQueryParameterST#listTasksFromUrlParametersTest

With the additional #<method name> - in this case listTasksFromUrlParametersTest you are only run this particular test.

⚠️ **GitHub.com Fallback** ⚠️