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
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 18. Unit Testing > Keeping Tests Atomic

18.7. Keeping Tests Atomic

18.7.1. Problem

When tests are lumped together, it’s possible to have tests that should pass but fail or tests that should fail but pass. This is a result of a test having invalid results because of side effects of a previous test:

test("2 asserts", function() {
    $("#main").append("<div>Click here for <span class='bold'>messages</span>.</div>");
    same($("#main div").length, 1, "added message link successfully");
    $("#main").append("<span>You have a message!</span>");
    same($("#main span").length, 1, "added notification successfully");
});

					  


  

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