Skip to main content

Unit Tests and TDD

  • Chapter
  • First Online:
Complete Guide to Test Automation

Abstract

While both acceptance-test-driven development (ATDD) and test-driven development (TDD) are methodologies that advocate writing the tests before the code, ATDD (or BDD) is usually considered to lend itself better to bigger test scopes and to scenarios that describe how the users use the system, while TDD is considered to lend itself more specifically to unit tests, which uses the smallest test scope (of a single class or even a method), and therefore tests more technical details. For that reason, unit tests and TDD are considered practices that are done directly by the same developer that implements the code under test (CUT). While toward the end of this chapter we’ll question the distinction between TDD and ATDD, we first need to understand more about unit tests and TDD in general.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 44.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 59.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    CUT can either mean “code under test” or “class under test.” I use this acronym interchangeably whenever the difference is not important or the meaning is clear from the context. Otherwise I’ll use the explicit term.

  2. 2.

    https://martinfowler.com/articles/is-tdd-dead/

  3. 3.

    As Martin Fowler said about the JUnit framework: “Never in the field of software development was so much owed by so many to so few lines of code.”

  4. 4.

    https://github.com/moq/moq4

  5. 5.

    Kent Beck, Test-Driven Development: By Example (Menlo Park, CA: Addison-Wesley, 2002).

  6. 6.

    Michael Feathers, Working Effectively with Legacy Code (Englewood Cliffs, NJ: Prentice Hall, 2004).

  7. 7.

    Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides, Design Patterns: Elements of Reusable Object-Oriented Software (Menlo Park, CA: Addison-Wesley Professional, 1994), p. 124.

  8. 8.

    In the Software-Engineering Radio podcast, episode 215, around minute 56 onward, the authors of the GOF book themselves discuss the problems with the Singleton pattern ( http://www.se-radio.net/2014/11/episode-215-gang-of-four-20-years-later/ ).

  9. 9.

    In his website, http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod , there are links to the major documents where these principles originally appeared.

  10. 10.

    http://blogs.microsoft.co.il/arnona/2011/08/26/tdd-and-the-solid-principles-part-1-introduction/

  11. 11.

    Martin Fowler, Kent Beck, John Brant, William Opdyke, and Don Roberts, Refactoring: Improving the Design of Existing Code (Menlo Park, CA: Addison-Wesley Professional, 1999).

  12. 12.

    https://martinfowler.com/bliki/UnitTest.html

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2018 Arnon Axelrod

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Axelrod, A. (2018). Unit Tests and TDD. In: Complete Guide to Test Automation. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-3832-5_17

Download citation

Publish with us

Policies and ethics