【问题标题】:how to run java/scala unit test in sbt如何在 sbt 中运行 java/scala 单元测试
【发布时间】:2022-01-02 20:03:03
【问题描述】:

我是 scala 的新手, scala 项目包含 scala 和 java 单元测试用例。

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 测试来运行。

【问题讨论】:

标签: java scala unit-testing sbt


【解决方案1】:

简答:尝试删除@RunWith(Suite.class)

【讨论】:

  • 是的,删除了 @RunWith(Suite.class) 并添加了 import org.junit.experimental.categories.Categories @RunWith(classOf[Categories]) 工作正常
猜你喜欢
  • 2023-03-26
  • 2018-10-18
  • 2020-07-05
  • 2014-11-11
  • 2023-03-18
  • 1970-01-01
  • 2014-03-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多