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

Pitest #594

Merged
merged 2 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ After starting the Spring Boot application (i.e. mvn spring-boot:run or via your
The source code of this test in at test/java/com/aidanwhiteley/books/loadtest/StressTestSimulation.java. The checked in config
ensures that, by default, the number of request per second is low enough not to stress an average PC.

#### Mutation Tests
There is support for mutation testing using the [Pitest](https://pitest.org/) library.
To try it out use something similar to
`mvn -Ppitest -DwithHistory=true -DtargetClasses="com.aidanwhiteley.books.service.*" test`
Be warned, the first run will take a long time (many minutes) - especially if the glob for targetClasses is wide. Subsequent runs should be much quicker.
Unfortunately, this mutation support wasn't in place when the tests were originally written meaning that the
current test suite have some tests that survive too many mutations! The mutation test code is there for any new code.


### How to build and run
This project makes use of the excellent Lombok project. So to build in your favourite IDE, if necessary
Expand Down
49 changes: 43 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@

<groupId>com.aidanwhiteley</groupId>
<artifactId>books</artifactId>
<version>0.50.4-RELEASE</version>
<version>0.50.5-RELEASE</version>
<packaging>jar</packaging>

<name>Books Microservice</name>
<description>A simple project to remind myself what books Ive read recently! Also a technology sampler using the
latest Spring Boot, oauth based logons, JWTs, stateless in the HTTP layer, Spring Boot admin, Mongo, Docker and docker-compose
latest Spring Boot, oauth based logons, JWTs, stateless in the HTTP layer, Spring Boot admin, Mongo, Docker and
docker-compose
</description>
<developers>
<developer>
Expand All @@ -33,7 +34,7 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.3.5</version>
<relativePath /> <!-- lookup parent from repository -->
<relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
Expand All @@ -45,7 +46,8 @@
<sonar.projectKey>com.aidanwhiteley:books</sonar.projectKey>
<sonar.organization>aidanwhiteley-github</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.coverage.jacoco.xmlReportPaths>${project.build.directory}/site/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
<sonar.coverage.jacoco.xmlReportPaths>${project.build.directory}/site/jacoco/jacoco.xml
</sonar.coverage.jacoco.xmlReportPaths>
</properties>

<dependencies>
Expand Down Expand Up @@ -271,7 +273,7 @@
<configuration>
<from>
<image>openjdk:21-jdk</image>
<!-- <image>amazoncorretto:21.0.0</image>-->
<!-- <image>amazoncorretto:21.0.0</image>-->
</from>
<to>
<image>aidanwhiteley/books-api-java</image>
Expand Down Expand Up @@ -308,8 +310,43 @@
<argLine>@{argLine} -javaagent:${net.bytebuddy:byte-buddy-agent:jar}</argLine>
</configuration>
</plugin>

</plugins>
</build>

<profiles>
<profile>
<id>pitest</id>
<build>
<plugins>
<plugin>
<groupId>org.pitest</groupId>
<artifactId>pitest-maven</artifactId>
<version>1.15.2</version>
<executions>
<execution>
<id>pitest</id>
<phase>test</phase>
<goals>
<goal>mutationCoverage</goal>
</goals>
</execution>
</executions>
<configuration>
<failWhenNoMutations>false</failWhenNoMutations>
<timestampedReports>false</timestampedReports>
<mutators>STRONGER</mutators>
</configuration>
<dependencies>
<dependency>
<groupId>org.pitest</groupId>
<artifactId>pitest-junit5-plugin</artifactId>
<version>1.2.1</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>