簡體   English   中英

如何在 sbt 中運行 java/scala 單元測試

[英]how to run java/scala unit test in sbt

我是 scala、scala 項目的新手,其中包含 scala 和 Z93F725A07423FE3D3337FZ48 單元測試用例。

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import itest.Level2;
    @RunWith(Suite.class)
    @Suite.SuiteClasses({Level2.class}) // Level2.class is contains @test method
    class  OrganizationRegexModelComponentTester  implements ITest{
    
    }

itest.jar 包含文件 Level2.class。 我加了

libraryDependencies += "junit" % "junit" % "4.11" % "test" // already added
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test"

testOnly company.extraction.api.util.TestJunitTwo 
[info] ScalaTest
[info] Run completed in 313 milliseconds.
[info] Total number of tests run: 0
[info] Suites: completed 0, aborted 0
[info] Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0
[info] No tests were executed.
[info] Passed: Total 0, Failed 0, Errors 0, Passed 0
[success] Total time: 7 s, completed Nov 24, 2021 1:17:53 PM

當我運行 - sbt test時,它只運行 scala 測試而不是 java 測試。 如何同時運行 java 和 scala 測試以運行。

簡短回答:嘗試刪除@RunWith(Suite.class)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM