简体   繁体   中英

how to run java/scala unit test in sbt

I am new to the scala, scala project contains both scala and java unit test cases.

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 contains file Level2.class. i added

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

when i run - sbt test it is running only scala tests not java tests. how to run both java and scala tests to run.

Short answer : try to remove @RunWith(Suite.class)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM