@Categoryと@RunWithアノテーションでJUnitテストを実行しません。@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:私はRunWithアノテーションを削除した場合
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' }
}
、Gradleのは、テストを実行します。 scanForTestClasses = falseの設定は無効です。
号。 – isobretatel
PowerMockは@Categoryアノテーションをプロキシで置き換えるようです:https://stackoverflow.com/questions/13377634/runwithpowermockrunner-class-does-not-work-with-package-annotation?rq=1 – isobretatel