Join Simon Allardice for an in-depth discussion in this video Using unit testing frameworks, part of Foundations of Programming: Test-Driven Development.
- View Offline
- [Voiceover] When I said that a large part…of what we're doing here is writing code…that tests our code, your brain may have even…wandered off on a little tangent…and thought about what that new code might look like.…And perhaps you'd thought,…well, if I'd written a new class and I wanted to test it,…I guess I could create another new class.…Call this one Tester.…In it, I'll instantiate that new class I'd just written.…I'll call a method on that new object.…I'd check the result and have a condition…that would fire off a message either way.…Yeah, you could do this.…It is reasonably simple code.…
But it would be very tedious code…to have to write a lot of this…and we will not have to do this.…Instead, there are unit testing frameworks we can use.…Things like JUnit for Java.…NUnit for .NET.…unittest for Python.…These are libraries of code already written,…already proven, that help us do automated unit testing,…providing a lot of that basic plumbing,…the duplicated structure we'd otherwise have to write.…Now, it would be easy to assume…
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