を開始しません@RepeatedTest
:私たちは、このようなTest Suiteからそれを実行しようとするまで@RepeatedTestは、我々が持っている。例えば
import org.junit.jupiter.api.RepeatedTest;
import static org.junit.jupiter.api.Assertions.assertEquals;
class SomeClassTest {
@RepeatedTest(3)
public void doSmth() {
String str = "hello";
SomeClass someClass = new SomeClass();
assertEquals(str.substring(0, 2), someClass.doSmth(str));
}
}
それは正常に動作します:
import org.junit.platform.runner.JUnitPlatform;
import org.junit.platform.suite.api.SelectClasses;
import org.junit.runner.RunWith;
@RunWith(JUnitPlatform.class)
@SelectClasses({
SomeClassTest.class
})
public class TestSuite {
}
SomeClass
public class SomeClass {
public String doSmth(String str){
return str.length() > 3? str.substring(0,2) : str;
}
}
コンソールにエラーはありません。テストは始まりません。 なぜですか?
更新
私はSomeClass
でロギングを有効に。
public class SomeClass {
private final static Logger log = LoggerFactory.getLogger(SomeClass.class.getName());
public String doSmth(String str){
log.info("in doSmth");
return str.length() > 3? str.substring(0,2) : str;
}
}
は今、私は@RepeatedTest
がテストスイート3回から呼び出されたことをログ・ファイルでご覧ください。しかし、後でテストはどうなるの?それはなぜ落ちるのですか?
JUnitの作業をログに記録する可能性がある場合は誰でも教えてください。また、現在のロジックで、私は、なぜテストだろうFAIL
か、他の理由が表示されない
private Logger log = Logger.getLogger(SomeTest.class.getName());
@BeforeEach
void beforeEach(TestInfo testInfo, RepetitionInfo repetitionInfo) {
log.info(String.format("About to execute repetition %d of %d for %s",
repetitionInfo.getCurrentRepetition(),
repetitionInfo.getTotalRepetitions(),
testInfo.getTestMethod().get().getName()));
}
- :
使用しているIntelliJのバージョンは何ですか? –
あなたのコードはEclipse Oxygen 4.7.1aでうまく動作します。したがって、セットアップやJUnit Jupiterに問題はありません。したがって、使用しているIntelliJのバージョンで問題になる可能性があります。 –
@SamBrannenご清聴ありがとう!私は 'IntelliJ IDEA 2017.2.5 ビルド番号IU-172.4343.14、2017年9月26日ビルド'を で 'JRE:1.8.0_152-release-915-b12 amd64; JVM:OpenJDK 64ビットサーバーVM JetBrains sro' – Woland