configured pitest mutation testing
This commit is contained in:
parent
2124d448bf
commit
9fb6610ec8
33
build.gradle
33
build.gradle
@ -7,6 +7,7 @@ plugins {
|
|||||||
id "org.owasp.dependencycheck" version "7.1.2"
|
id "org.owasp.dependencycheck" version "7.1.2"
|
||||||
id "com.diffplug.spotless" version "6.10.0"
|
id "com.diffplug.spotless" version "6.10.0"
|
||||||
id 'jacoco'
|
id 'jacoco'
|
||||||
|
id 'info.solidsoft.pitest' version '1.7.4'
|
||||||
id 'se.patrikerdes.use-latest-versions' version '0.2.18'
|
id 'se.patrikerdes.use-latest-versions' version '0.2.18'
|
||||||
id 'com.github.ben-manes.versions' version '0.42.0'
|
id 'com.github.ben-manes.versions' version '0.42.0'
|
||||||
}
|
}
|
||||||
@ -72,6 +73,8 @@ dependencies {
|
|||||||
testImplementation 'org.testcontainers:postgresql'
|
testImplementation 'org.testcontainers:postgresql'
|
||||||
testImplementation 'com.tngtech.archunit:archunit-junit5:1.0.0-rc1'
|
testImplementation 'com.tngtech.archunit:archunit-junit5:1.0.0-rc1'
|
||||||
testImplementation 'io.rest-assured:spring-mock-mvc'
|
testImplementation 'io.rest-assured:spring-mock-mvc'
|
||||||
|
testImplementation 'org.hamcrest:hamcrest-core:2.2'
|
||||||
|
testImplementation 'org.pitest:pitest-junit5-plugin:1.0.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencyManagement {
|
dependencyManagement {
|
||||||
@ -213,6 +216,36 @@ jacocoTestCoverageVerification {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pitest mutation testing
|
||||||
|
pitest {
|
||||||
|
targetClasses = ['net.hostsharing.hsadminng.**']
|
||||||
|
excludedClasses = [
|
||||||
|
'net.hostsharing.hsadminng.config.**',
|
||||||
|
'net.hostsharing.hsadminng.generated.**'
|
||||||
|
]
|
||||||
|
|
||||||
|
targetTests = ['net.hostsharing.hsadminng.**.*UnitTest', 'net.hostsharing.hsadminng.**.*RestTest']
|
||||||
|
excludedTestClasses = ['**AcceptanceTest*', '**IntegrationTest*']
|
||||||
|
|
||||||
|
pitestVersion = '1.9.0'
|
||||||
|
junit5PluginVersion = '1.0.0'
|
||||||
|
|
||||||
|
threads = 4
|
||||||
|
|
||||||
|
// As Java unit tests are pretty pointless in our case, this maybe makes not much sense.
|
||||||
|
mutationThreshold = 31
|
||||||
|
coverageThreshold = 44
|
||||||
|
testStrengthThreshold = 76
|
||||||
|
|
||||||
|
outputFormats = ['XML', 'HTML']
|
||||||
|
timestampedReports = false
|
||||||
|
}
|
||||||
|
project.tasks.check.dependsOn(project.tasks.pitest)
|
||||||
|
project.tasks.pitest.doLast {
|
||||||
|
println "PiTest Mutation Report: file:///${project.rootDir}/build/reports/pitest/index.html"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Dependency Versions Upgrade
|
// Dependency Versions Upgrade
|
||||||
useLatestVersions {
|
useLatestVersions {
|
||||||
finalizedBy check
|
finalizedBy check
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
postgresql.version = 42.4.1
|
postgresql.version = 42.4.1
|
||||||
|
|
||||||
# TODO: can be removed if all dependencies are JDK 16 compliant
|
# TODO: can be removed if all dependencies are JDK 16 compliant
|
||||||
#org.gradle.jvmargs= \
|
org.gradle.jvmargs= \
|
||||||
# --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
|
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED \
|
||||||
# --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
|
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED \
|
||||||
# --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
|
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED \
|
||||||
# --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
|
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED \
|
||||||
# --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
|
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package net.hostsharing.hsadminng.arch;
|
package net.hostsharing.hsadminng.arch;
|
||||||
|
|
||||||
import com.tngtech.archunit.junit.AnalyzeClasses;
|
import com.tngtech.archunit.junit.AnalyzeClasses;
|
||||||
import com.tngtech.archunit.junit.ArchTest;
|
|
||||||
import com.tngtech.archunit.lang.ArchRule;
|
import com.tngtech.archunit.lang.ArchRule;
|
||||||
import net.hostsharing.hsadminng.Accepts;
|
import net.hostsharing.hsadminng.Accepts;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@ -11,61 +10,61 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.*;
|
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.*;
|
||||||
import static com.tngtech.archunit.library.dependencies.SlicesRuleDefinition.slices;
|
import static com.tngtech.archunit.library.dependencies.SlicesRuleDefinition.slices;
|
||||||
|
|
||||||
@AnalyzeClasses(packages = ArchUnitTest.NET_HOSTSHARING_HSADMINNG)
|
@AnalyzeClasses(packages = ArchTest.NET_HOSTSHARING_HSADMINNG)
|
||||||
public class ArchUnitTest {
|
public class ArchTest {
|
||||||
|
|
||||||
public static final String NET_HOSTSHARING_HSADMINNG = "net.hostsharing.hsadminng";
|
public static final String NET_HOSTSHARING_HSADMINNG = "net.hostsharing.hsadminng";
|
||||||
|
|
||||||
@ArchTest
|
@com.tngtech.archunit.junit.ArchTest
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public static final ArchRule contextPackageRule = classes()
|
public static final ArchRule contextPackageRule = classes()
|
||||||
.that().resideInAPackage("..context..")
|
.that().resideInAPackage("..context..")
|
||||||
.should().onlyDependOnClassesThat()
|
.should().onlyDependOnClassesThat()
|
||||||
.resideOutsideOfPackage(NET_HOSTSHARING_HSADMINNG);
|
.resideOutsideOfPackage(NET_HOSTSHARING_HSADMINNG);
|
||||||
|
|
||||||
@ArchTest
|
@com.tngtech.archunit.junit.ArchTest
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public static final ArchRule configPackageRule = classes()
|
public static final ArchRule configPackageRule = classes()
|
||||||
.that().resideInAPackage("..config..")
|
.that().resideInAPackage("..config..")
|
||||||
.should().onlyDependOnClassesThat()
|
.should().onlyDependOnClassesThat()
|
||||||
.resideOutsideOfPackage(NET_HOSTSHARING_HSADMINNG);
|
.resideOutsideOfPackage(NET_HOSTSHARING_HSADMINNG);
|
||||||
|
|
||||||
@ArchTest
|
@com.tngtech.archunit.junit.ArchTest
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public static final ArchRule errorsPackageRule = classes()
|
public static final ArchRule errorsPackageRule = classes()
|
||||||
.that().resideInAPackage("..errors..")
|
.that().resideInAPackage("..errors..")
|
||||||
.should().onlyDependOnClassesThat()
|
.should().onlyDependOnClassesThat()
|
||||||
.resideOutsideOfPackage(NET_HOSTSHARING_HSADMINNG);
|
.resideOutsideOfPackage(NET_HOSTSHARING_HSADMINNG);
|
||||||
|
|
||||||
@ArchTest
|
@com.tngtech.archunit.junit.ArchTest
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public static final ArchRule hsPackagesRule = classes()
|
public static final ArchRule hsPackagesRule = classes()
|
||||||
.that().resideInAPackage("..hs.(*)..")
|
.that().resideInAPackage("..hs.(*)..")
|
||||||
.should().onlyBeAccessed().byClassesThat()
|
.should().onlyBeAccessed().byClassesThat()
|
||||||
.resideInAnyPackage("..hs.(*)..");
|
.resideInAnyPackage("..hs.(*)..");
|
||||||
|
|
||||||
@ArchTest
|
@com.tngtech.archunit.junit.ArchTest
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public static final ArchRule hsPackagePackageRule = classes()
|
public static final ArchRule hsPackagePackageRule = classes()
|
||||||
.that().resideInAPackage("..hs.hspackage..")
|
.that().resideInAPackage("..hs.hspackage..")
|
||||||
.should().onlyBeAccessed().byClassesThat()
|
.should().onlyBeAccessed().byClassesThat()
|
||||||
.resideInAnyPackage("..hs.hspackage..");
|
.resideInAnyPackage("..hs.hspackage..");
|
||||||
|
|
||||||
@ArchTest
|
@com.tngtech.archunit.junit.ArchTest
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public static final ArchRule acceptsAnnotationOnMethodsRule = methods()
|
public static final ArchRule acceptsAnnotationOnMethodsRule = methods()
|
||||||
.that().areAnnotatedWith(Accepts.class)
|
.that().areAnnotatedWith(Accepts.class)
|
||||||
.should().beDeclaredInClassesThat().haveSimpleNameEndingWith("AcceptanceTest")
|
.should().beDeclaredInClassesThat().haveSimpleNameEndingWith("AcceptanceTest")
|
||||||
.orShould().beDeclaredInClassesThat().haveSimpleNameNotContaining("AcceptanceTest$");
|
.orShould().beDeclaredInClassesThat().haveSimpleNameNotContaining("AcceptanceTest$");
|
||||||
|
|
||||||
@ArchTest
|
@com.tngtech.archunit.junit.ArchTest
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public static final ArchRule acceptsAnnotationOnClasesRule = classes()
|
public static final ArchRule acceptsAnnotationOnClasesRule = classes()
|
||||||
.that().areAnnotatedWith(Accepts.class)
|
.that().areAnnotatedWith(Accepts.class)
|
||||||
.should().haveSimpleNameEndingWith("AcceptanceTest")
|
.should().haveSimpleNameEndingWith("AcceptanceTest")
|
||||||
.orShould().haveSimpleNameNotContaining("AcceptanceTest$");
|
.orShould().haveSimpleNameNotContaining("AcceptanceTest$");
|
||||||
|
|
||||||
@ArchTest
|
@com.tngtech.archunit.junit.ArchTest
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public static final ArchRule doNotUseJavaxTransactionAnnotationAtClassLevel = noClasses()
|
public static final ArchRule doNotUseJavaxTransactionAnnotationAtClassLevel = noClasses()
|
||||||
.should().beAnnotatedWith(javax.transaction.Transactional.class.getName())
|
.should().beAnnotatedWith(javax.transaction.Transactional.class.getName())
|
||||||
@ -73,7 +72,7 @@ public class ArchUnitTest {
|
|||||||
org.springframework.transaction.annotation.Transactional.class.getName(),
|
org.springframework.transaction.annotation.Transactional.class.getName(),
|
||||||
javax.transaction.Transactional.class));
|
javax.transaction.Transactional.class));
|
||||||
|
|
||||||
@ArchTest
|
@com.tngtech.archunit.junit.ArchTest
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public static final ArchRule doNotUseJavaxTransactionAnnotationAtMethodLevel = noMethods()
|
public static final ArchRule doNotUseJavaxTransactionAnnotationAtMethodLevel = noMethods()
|
||||||
.should().beAnnotatedWith(javax.transaction.Transactional.class)
|
.should().beAnnotatedWith(javax.transaction.Transactional.class)
|
||||||
@ -81,7 +80,7 @@ public class ArchUnitTest {
|
|||||||
org.springframework.transaction.annotation.Transactional.class.getName(),
|
org.springframework.transaction.annotation.Transactional.class.getName(),
|
||||||
javax.transaction.Transactional.class.getName()));
|
javax.transaction.Transactional.class.getName()));
|
||||||
|
|
||||||
@ArchTest
|
@com.tngtech.archunit.junit.ArchTest
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public static final ArchRule doNotUseOrgJUnitTestAnnotation = noMethods()
|
public static final ArchRule doNotUseOrgJUnitTestAnnotation = noMethods()
|
||||||
.should().beAnnotatedWith(org.junit.Test.class)
|
.should().beAnnotatedWith(org.junit.Test.class)
|
Loading…
Reference in New Issue
Block a user