blasrodri
blasrodri

Reputation: 446

Cannot run tests with org.scalatest.tools.Runner from command line

I have my test compiled in a directory: samplesuite It works when running one Suite using org.scalatest.run. Nothing happens when I try to run the directory that contains several suites.

scala -cp "..\mytestframework\target\scala-2.12\mytestframework-assembly-0.1.jar;../../Downloads/scalactic_2.12-3.0.5.jar;..\..\Downloads\scalatest_2.12-3.0.5.jar" org.scalatest.run samplesuite.SomeSpec

But it won't run when trying:

    scala -cp "..\mytestframework\target\scala-2.12\mytestframework-assembly-0.1.jar;../../Downloads/scalactic_2.12-3.0.5.jar;..\..\Downloads\scalatest_2.12-3.0.5.jar" org.scalatest.tools.Runner -R samplesuite

Upvotes: 3

Views: 984

Answers (1)

Mario Galic
Mario Galic

Reputation: 48420

Assuming tests are defined in package samplesuite, for example

package samplesuite
class SomeSpec extends FlatSpec with Matchers

and current working directory . is one level above samplesuite, then discover and run all suites with

scala -cp "..\mytestframework\target\scala-2.12\mytestframework-assembly-0.1.jar;../../Downloads/scalactic_2.12-3.0.5.jar;..\..\Downloads\scalatest_2.12-3.0.5.jar" org.scalatest.tools.Runner -R .

In general, when specifying runpath from which tests will be discovered with -R point to the root directory where your packages start, or to the .jar file generated with sbt test:package:

scala -cp target/scala-2.12/classes:scalatest_2.12-3.0.5.jar:scalactic_2.12-3.0.5.jar org.scalatest.tools.Runner -R target/scala-2.12/test-classes

scala -cp target/scala-2.12/classes:scalatest_2.12-3.0.5.jar:scalactic_2.12-3.0.5.jar org.scalatest.tools.Runner -R target/scala-2.12/how-can-i-perform-an-or-with-scalatest_2.12-0.1.0-SNAPSHOT-tests.jar

Upvotes: 2

Related Questions