O'Reilly logo

Lift Application Development Cookbook by Gilberto T. Garcia Jr.

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

Testing snippets using Specs2

We cannot dilute the importance of testing software. The only way we can guarantee that our software works and will keep working after we have changed, refactored, and applied new features to it, is by testing it.

Getting ready

We'll use the code from the Creating an HTML list using CSS selectors recipe.

How to do it...

  1. Create a file called AnimalsSpec in src/test/scala/code/snippet with the following content:
    import org.specs2.mutable._ class AnimalsSpec extends Specification { "Animals list" should { "contains 5 animals" in { val result = <ul><li><span class="name">Dog</span> - <span class="sname">(Canis lupus familiaris)</span></li><li><span class="name">Cat</span> - <span class="sname">(Felis catus)</span></li><li><span ...

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