Home > Net >  How to run single test from test class scala?
How to run single test from test class scala?

Time:04-12

I have such class with tests:

class TestSuite {

  @Test def one(): Unit = {
    println(1)
  }

  @Test def two(): Unit = {
    println(2)
  }

  @Test def three(): Unit = {
    println(3)
  }
}

I would like to run only for example test with name three and don't run another ones. I have maven project with 2.13.6 scala version so I tried to run single test via this command:

 mvn test -Dtest="TestSuite@two"

but I got the error which is posted below:

 No tests were executed!  (Set -DfailIfNoTests=false to ignore this error.)

I saw this command on the official maven docs so I thought that it will work well, but it didn't. So, maybe I did smth wrong and we have another command for running one test from testing class and ignoring another ones?

CodePudding user response:

and we have another command for running one test from testing class and ignoring another ones?

That should be possible, but using ScalaTest with maven, or ScalaTest with sbt.

  • Related