Test paradigms and methods

There are numerous competing and complementary theories regarding software testing and development methodologies. Reading up on the world of test methods provides an excellent background for any developer looking to improve the ways in which they construct, implement, and manage tests. For brevity's sake, we will only introduce two paradigms in this book that are particularly useful for Backbone.js testing—Test-Driven Development (TDD) and Behavior-Driven Development (BDD).

Test-Driven Development is a process wherein tests are written first and then the actual code is written. The benefits of this approach include:

  • Making tests a first-class priority in the development process
  • Encouraging code to be written in small modular units
  • Preventing the knowledge of code implementation details from unduly influencing the tests

TDD and general software testing principles are covered in many resources; a recommended reference on the subject is Growing Object-Oriented Software, Guided by Tests by Steve Freeman and Nat Pryce (http://www.amazon.com/Growing-Object-Oriented-Software-Guided-Tests/dp/0321503627).

Note

For the purpose of readability, we usually present the code first and the tests second. However, this is not necessarily the order in which the code and tests would be developed. Notwithstanding our examples, we strongly encourage that you incorporate TDD practices into your software development process.

Behavior-Driven Development is a refinement to TDD. It was developed by Dan North (http://dannorth.net/introducing-bdd/), and centers around specifying and describing tests in terms of the desired behavior of the application. In other words, BDD tests focus on what the application should be doing and not what the test code is testing, causing developers to ideally think less about internal test details and more about the application as a whole. To learn more about the principles and applications of BDD, a great starting point is the http://behaviour-driven.org/ website.

Tip

BDD and TDD as library configuration options

The BDD and TDD paradigms are so prevalent in the testing vernacular that many test libraries have adopted the terms BDD or TDD to designate APIs and configurations. For example, in Chapter 3, Test Assertions, Specs, and Suites, we'll explore the Mocha bdd and tdd API interfaces. To avoid any confusion, it is best to view test library modes as just configuration options that may or may not have a strict relationship to the paradigms we have just discussed.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.203.43