Farah
Farah

Reputation: 2621

How to run Test Suites sequentially in ScalaTest / SBT?

How to run Test Suites sequentially in ScalaTest / SBT?

For example if I have this test suites A, B and C I want to make sure that the tests of A will be run 1st then the ones of B then the ones of C.

Is there in configuration that I can make in Scalatest or SBT?

Thank you.

Upvotes: 5

Views: 2958

Answers (3)

pme
pme

Reputation: 14803

As raj mehra said, the solution is to configure to run the tests not in parallel.

Test / parallelExecution := false

Former parallelExecution in Test := false is deprecated.

Here is the Documentation that explains it: SBT Parallel Execution

From it:

As before, parallelExecution in Test controls whether tests are mapped to separate tasks.

Upvotes: 1

gccodec
gccodec

Reputation: 342

According to the documentation http://doc.scalatest.org/1.7/org/scalatest/Suite.html

You need to create your own Test Suite like the following:

FirstTest.scala

import org.scalatest.{DoNotDiscover, FunSuite}

@DoNotDiscover
class FirstTest extends FunSuite {

  test("first test"){
    assert(1 == 1)
  }

}

SecondTest.scala

import org.scalatest.{DoNotDiscover, FunSuite}

@DoNotDiscover
class SecondTest extends FunSuite{

  test("second test"){
    assert(2 == 2)
  }
}

MainTest.scala

import org.scalatest.Suites
class MainTest extends Suites (new FirstTest,new SecondTest)

Now, if you run sbt test it's work properly.

Notes: the property @DoNotDiscover is mandatory. this avoid unexpected behavior like execution of FirstTest and SecondTest after the execution of the MainSuite that are already executed the two test suites.

I hope it was helpful

Upvotes: 2

raj mehra
raj mehra

Reputation: 21

try using parallelExecution in Test := false

Upvotes: 2

Related Questions