Problem: When using ScalaTest, you want to temporarily disable one or more tests, presumably until you can get them working again.
Solution
When using BDD-style tests, change it
method calls to ignore
:
ignore ("A new pizza has zero toppings", DatabaseTest) { Given("a new pizza") pizza = new Pizza Then("the topping count should be zero") assert(pizza.getToppings.size == 0) }
With TDD-style tests, change test
method calls to ignore
:
ignore ("A new pizza has zero toppings", DatabaseTest) { //assert(pizza.getToppings.size === 1) expectResult(0) { pizza.getToppings.size } }
When you run your tests, the tests you changed to ignore will result in output similar to the following:
[info] - A new pizza has zero toppings !!! IGNORED !!!
When run from the command line using SBT, this output is displayed in a yellow font.
Discussion
Many times when testing your code, you’ll need to temporarily disable some tests until you can get them working again. Changing it
and test
to ignore
is a simple way to change the tests so they’ll be skipped over. The output is a hard-to-miss reminder that the tests are being ignored.
this post is sponsored by my books: | |||
#1 New Release |
FP Best Seller |
Learn Scala 3 |
Learn FP Fast |
See Also
See these links for more information:
- Writing TDD Tests with ScalaTest
- Writing a First BDD Test with ScalaTest
- More information on tagging your tests with ignore: http://www.scalatest.org/user_guide/tagging_your_tests