In my Spring Boot app I have a suite of Gradle tests that I can run with ./gradlew test
. Is there a way I can run one package of tests before all the others, eg com/example/myapp/firstpackage/**
.
I know that I can run only these tests with the following config
test {
useJUnitPlatform()
include 'com/example/myapp/firstpackage/**'
}
But what I actually want to do is run the tests in this package at the beginning of the task, and then run the rest.
Can not do this in Junit 5.
you have to switch to junit 4 - execution wise.
one way to do this is
@RunWith(JUnitPlatform.class)
@SuiteDisplayName("JUnit Platform Ordered Suite ")
@SelectClasses({Test1.class, Test2.class, Test3.class, Test4.class})
public class TestOrderedSuite {
}
dependencies {
testCompileOnly 'junit:junit:4.13'
testImplementation 'org.junit.jupiter:junit-jupiter:5.7.0'
testImplementation 'org.junit.platform:junit-platform-suite-api:1.7.0'
testImplementation 'org.junit.platform:junit-platform-runner:1.7.0'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.7.0'
}
test {
// useJUnitPlatform()
useJUnit()
}
add a test task (lets call it smoke tests) and let the default test task depend on it
task smokeTest(type: Test) {
useJUnitPlatform()
include 'com/example/myapp/firstpackage/**'
}
test {
useJUnitPlatform()
exclude 'com/example/myapp/firstpackage/**'
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.