IntelliJ IDEAでJUnit 5を学ぼうとしています。テストクラスを作成し、1つのメソッドをテストしようとしました。ここでのメッセージは、(三行目を参照)です。JUnitは私のテスト方法を "独自の方法に解決できませんでした"と言っています
INFO: Discovered TestEngines with IDs: [junit-jupiter]
Internal Error occurred.
org.junit.platform.commons.util.PreconditionViolationException:'DirectoryTest#directory2bytes' could not be resolved to a unique method
at org.junit.platform.engine.discovery.DiscoverySelectors.lambda$selectMethod$1(DiscoverySelectors.java:131)
at java.util.Optional.orElseThrow(Optional.java:290)
at org.junit.platform.engine.discovery.DiscoverySelectors.selectMethod(DiscoverySelectors.java:130)
at com.intellij.junit5.JUnit5TestRunnerUtil.createSelector(JUnit5TestRunnerUtil.java:111)
at com.intellij.junit5.JUnit5TestRunnerUtil.buildRequest(JUnit5TestRunnerUtil.java:86)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:46)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Process finished with exit code 254
Empty test suite.
方法は解決できない理由を私は理解することはできません:それはコンパイルし、それは間違いなくあります:
@Test
void directory2bytes() {
testBytes = testDir.directory2bytes();
for(int i = 0; i <= 10; i++) {
System.out.print(testBytes[i] + " ")
}
System.out.println();
}
そして、私はこれを定義しています:
@BeforeEach
void setUp() {
testDir = new Directory()
testBytes = new byte[1000];
}
更新:終了してのIntelliJ IDEAをリニューアル、私は今、さまざまな注釈「@beforeEach」と一緒に、インポートされたシンボル「JUnitのは」解決できないメッセージを取得しています、「afterEach」と「テスト」 。
更新2:テストクラスでセミコロンが見つかりませんでしたが、変更はありません。注:私はテストしていないクラスの中にはコンパイルエラーがありますが、テストの実行設定は「ビルド、エラーチェックなし」に設定されています。これは正しいですか?私はJUnit 4を使って同じテストを(別のクラス名で)作成しようとしましたが、どちらもうまくいきません。などTest
でアノテート
Dec 07, 2016 9:51:41 AM org.junit.platform.launcher.core.ServiceLoaderTestEngineRegistry loadTestEngines
INFO: Discovered TestEngines with IDs: [junit-jupiter, junit-vintage]
Internal Error occurred.
org.junit.platform.commons.util.PreconditionViolationException: Could not load class with name: DirectoryTest
at org.junit.platform.engine.discovery.MethodSelector.lambda$lazyLoadJavaClass$0(MethodSelector.java:154)
これを追加しようとしましたが、明らかに記録されませんでした。プロジェクト構造の「依存関係」タブで、「ライブラリJUnit5がパスを壊しました」というメッセージが表示されます。 –
GitHubに縮小したサンプルプロジェクトを作成して、あなたが遭遇しているエラーを実証することができますか? –
また、IDEAで新しいプロジェクトを作成して、既存のプロジェクトで問題が解決したかどうか確認しましたか? –