Join Simon Allardice for an in-depth discussion in this video Understanding assertions, part of Foundations of Programming: Test-Driven Development.
- Before I write my first line of testing code…I want to talk about the most basic word in unit testing,…one that we will use all the time…and that word is assert.…To assert is to state something positively.…I assert that the earth moves around the sun.…I'm not asking a question.…This is not an if.…I'm not inviting opinion.…I'm not trying to change or alter anything.…I am simply stating something to be true.…Now these assertions can be positive.…I an asserting something is true.…
I assert there are only 30 days in April.…But assertions could also be negatively.…So I am asserting something is not true.…I assert the book, War and Peace,…was not written by Ernest Hemingway…but I'm not presenting any of these as opinion.…I'm saying these are facts.…Now it is possible an assertion I make could be wrong.…But if my assertion is wrong,…then there is something fundamentally…flawed with whatever I'm talking about.…So we take this idea over to programming.…
We can make assertions at any point in our code.…At this point in my code, I assert these two strings…
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