Testing SpringBoot Applications: disabling specific tests - andretti1977/linux-commands GitHub Wiki
If you want to disable specific tests you can't simply create an annotation and then apply it to the the @Test annotated method. Since @RunWith specifies the runner, it is responsability for the runner to consider custom annotations since it's not Spring embedding them. If you create custom annotations that you apply to the methods the test invoke, then those annotations are correctly executed.
If you want to skip some method you have to use @IfProfileValue annotation.
This annotation requires a system environment variable (not a one read from application.properties) so you must set it on system or pass it to gradle.
To pass it to gradle you must invoke gradle with the variable i.e.:
./gradlew cleanTest test integrationTest --tests com.criptalia.fundsoperations.HoldTests -Drun.intensive.tests=true
And in your build.gradle read it and set for the environment:
task integrationTest(type: Test) {
systemProperty "runIntensiveTests", System.getProperty("run.intensive.tests")
testClassesDirs = sourceSets.integrationTest.output.classesDirs
classpath = sourceSets.integrationTest.runtimeClasspath
outputs.upToDateWhen { false }
}
Then in your code:
@IfProfileValue(name="runIntensiveTests", value = "true")
@Test
public void allowHoldForMultipleOrdersWithFunds() {
System.out.println("test is running");
Interesting approach is the one linked here where you can define your own Runner, but it didn't work for me at first:
https://stackoverflow.com/questions/19981659/create-own-test-annotation-for-junit