Gradle不會使用@Category和@RunWith註釋運行我的JUnit測試。Gradle測試任務不會使用@Category和@RunWith註釋運行JUnit測試
Java 8,Gradle 4.2.1。
我的JUnit類:
public interface FastTest {
}
@Category(FastTest.class)
@RunWith(PowerMockRunner.class)
public class MyTest {
@Test
public void testMyMethod() {
// Test method should fail
assertTrue(false);
}
}
我的build.gradle:
apply plugin: 'java'
repositories { mavenCentral() }
dependencies {
compile "junit:junit:4.12"
compile "org.powermock:powermock-core:1.6.5"
compile "org.powermock:powermock-api-mockito-common:1.6.5"
compile "org.powermock:powermock-module-junit4:1.6.5"
compile "org.powermock:powermock-api-mockito:1.6.5"
}
test {
scanForTestClasses = false
useJUnit { includeCategories 'FastTest' }
}
如果我刪除RunWith註釋,搖籃運行測試。 scanForTestClasses = false設置不起作用。
號它是搖籃。 – isobretatel
它看起來像PowerMock用代理替換@Category註釋:https://stackoverflow.com/questions/13377634/runwithpowermockrunner-class-does-not-work-with-package-annotation?rq=1 – isobretatel