Join Simon Allardice for an in-depth discussion in this video Common questions on individual tests, part of Foundations of Programming: Test-Driven Development.
- [Voiceover] I want to finish up this section…by going through a few questions and issues…that are common to hear at this time…including a couple of things that…I referred to earlier.…We'll begin with the question…do I need to test things like the…get and set methods of properties?…And this really depends.…If you have simple getters and setters…that are just the equivalent of…returning or setting internal balances,…or if you're using a language that…generates or synthesizes them,…then no, these don't need testing.…There is no point at all to creating…specific unit tests for this kind of stuff…because there's simply nothing you could do if it failed.…
You're trying to test everything that could break…and that you could then fix,…you're not trying to test the language itself,…you're testing your own logic.…So it's fine to assume that some things will just work,…that a return statement will work,…that if you add two and two, you will get four.…That's not the kind of stuff that needs tested.…Now if however, you need a custom setter method…
The course explores the jargon of TDD—test suites, test harness, mock and stub objects, and more—and covers how TDD is used in the most common programming languages and environments. Plus learn to create, run, and manage the tests and move to a test-first mindset.
- What is test-driven development?
- Using unit testing frameworks
- Creating tests
- Using assertions
- Creating multiple test methods
- Naming unit tests and test methods
- Testing return values
- Setting up and tearing down
- Introducing mock objects
- Measuring code coverage