Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable test suite in ScalaTest

How to disable a test suite, i.e. all tests inside class extending FunSpec?

The only solution I'd found is to replace it with ignore in front of each test, but it is boring to do so with the dozens of tests.

like image 691
lambdas Avatar asked Jul 17 '12 04:07

lambdas


People also ask

How do you ignore test cases in ScalaTest?

It has been inserted into Scaladoc by pretending it is a trait. When you mark a test class with a tag annotation, ScalaTest will mark each test defined in that class with that tag. Thus, marking the SetSpec in the above example with the @Ignore tag annotation means that both tests in the class will be ignored.

How do I disable test cases in Gtest?

The docs for Google Test 1.7 suggest: If you have a broken test that you cannot fix right away, you can add the DISABLED_ prefix to its name. This will exclude it from execution. This is better than commenting out the code or using #if 0 , as disabled tests are still compiled (and thus won't rot).


2 Answers

The easy way to do this in 1.8 is to add a constructor that takes a dummy argument. ScalaTest (and sbt) won't discover the class if it doesn't have a public, no-arg constructor:

class MySuite(ignore: String) extends FunSuite {    // ... } 

In 2.0 you'll be able to just write @Ignore on the class:

@Ignore class MySuite extends FunSuite {   // ... } 
like image 93
Bill Venners Avatar answered Oct 14 '22 07:10

Bill Venners


You can use @Ignore both for distinct tests and the whole suit.

like image 39
Mitch Sitin Avatar answered Oct 14 '22 08:10

Mitch Sitin