Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Assertions

As a developer, if you have used JUnit6 (or any of the flavors of JUnit), you already have some idea what an assertion is. An assertion is used to validate that an expected condition is true. If the expected condition is not true, a java.lang.AssertionError 7 is thrown. You test that the expected condition is true by using Groovy expressions.

Taking advantage of Groovy's truth8 required Groovy developers to create their own version of assert. They could not leverage the Java version of assert9 because it is restricted to Java's version of truth. You will also notice that the syntax is the same. Listing 2-10 illustrates the Java and Groovy versions of assert.

_______________


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint