ScalaTest 107: How to mark a test as ‘pending’

Problem: You want to note that a ScalaTest unit test needs to be created, but you’re not ready to write it yet.

Solution

Instead of supplying the body of a test method, mark the test as pending. In the ScalaTest TDD style, create a pending test like this:

test ("should allow removal of toppings") (pending)

In the ScalaTest BDD style, create a pending test like this:

it("should allow removal of toppings") (pending)

When your tests are run, pending tests will be printed like this:

[info] - should allow addition of toppings (pending)

Discussion

When tests are run at the command line with SBT, pending lines are printed in a yellow(ish) color.

Marking tests as pending helps support the TDD style, and it’s a convenient way of saying, “I need to write this test and implement the code behind it, but I haven’t gotten there yet.”

See Also

I hope it has been helpful. All the best, Al.