Join Simon Allardice for an in-depth discussion in this video Setting up and tearing down, part of Programming Foundations: Test-Driven Development.
- [Voiceover] We've explored a couple of concepts already,…first that for each of the,…what you might think of as regular classes…in your application,…you would typically create separate unit test class files…and in each unit test class,…you'd have multiple simple, self contained test methods.…Each testing a specific path through the methods…and the relevant application class,…and we've also seen that these individual test methods…themselves usually consist of the three A approach.…We arrange, we act, and we assert.…
We setup some objects and values,…we do something to them,…then we check the results,…and what is very common is that multiple test methods…in the same unit test class end up beginning…with a very similar arrangement of data,…a very similar setup.…Often, they're going to repeat the same code…to initialize the current object under test…with some simple data.…Now here I'm just creating a bank account object…inside each test method,…and I might be able to do it in one line,…but often you'd need multiple lines to setup an object…
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