我運(yùn)行 JUnit5 測試但收到initializationError( No runnable methods)。但是,我@Test至少有一個方法 ( failingTest) 的注釋。為什么failingTest不被識別為可運(yùn)行方法(并執(zhí)行相應(yīng)的測試用例)?文件StandardTests.java...// See https://junit.org/junit5/docs/current/user-guide/#writing-tests-classes-and-methodsimport static org.junit.jupiter.api.Assertions.fail ;import org.junit.jupiter.api.Test ;public class StandardTests { @Test public void failingTest() { fail ( "a failing test" ) ; } } // end StandardTests并在文件中TestRunner.java...import org.junit.runner.JUnitCore ;import org.junit.runner.Result ;import org.junit.runner.notification.Failure ;public class TestRunner { public static void main ( String [] args ) { Result result = JUnitCore.runClasses ( StandardTests.class ) ; for ( Failure failure : result.getFailures() ) System.out.println ( "failure: " + failure.toString() ) ; System.out.println ( "successful: " + result.wasSuccessful() ) ; } // end main } // end TestRunnerfailingTest我希望類的方法StandardTests將被識別為 JUnit5 測試用例并執(zhí)行(也就是說,failingTest將被識別為runnable method并作為 JUnit5 測試用例執(zhí)行)。但是,我運(yùn)行時的輸出TestRunner是:C:\JUnit\Minimal>C:\Progra~1\Java\JDK-12~1.1\bin\java -cp ".;junit-platform-console-standalone-1.4.2.jar" TestRunnerfailure: initializationError(StandardTests): No runnable methodssuccessful: false我如何才能將這個 JUnit5 測試用例 ( failingTest) 識別為測試用例并執(zhí)行?
JUnit5如何識別和執(zhí)行可運(yùn)行的方法?
呼喚遠(yuǎn)方
2023-02-23 15:50:28