O'Reilly logo

Scala Test-Driven Development by Gaurav Sood

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. Clean Code Using ScalaTest

In this chapter, we will look at some examples of writing clean test code. You will also continue your learning of ScalaTest. We will explore the following:

  • Assertions
  • Matchers
  • Base test classes
  • Test fixtures

Note

Some of the text and examples in this chapter has been cited with the consent from official ScalaTest documentation at www.scalatest.org. This text and example is copyright of Artima, Inc.

Assertions

There are three default assertions that come out of the box with ScalaTest:

  • assert:

    We used this in Chapter 2, First Test-Driven Application. This is used for general assertions:

         test("one plus one") {      
             assert(1 + 1 == two)      
             assert(1 + 1 != three)    
          }
  • assertResult:

    This is used to differentiate between the expected ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required