Testing Flashcards
Osherove book
What is a unit test?
an automated piece of code that invokes another piece of code and checks one specific end result. The scope can be from a single method to multiple classes.
Properties of good unit tests
1) automated & repeatable
2) easy to implement
3) relevant in the future
4) runs quickly & easily (push of a button)
5) consistent in results
6) has full control of unit under test
7) isolated
8) when it fails the cause is easy to identify
(think of each individual car part, not the whole system)
What is an integration test?
Any test that is not fast, consistent, and/or uses dependencies. (Think of the whole car as a system)
What kind of test is one that uses the current time?
Integration (it’s not consistent)
What is a “regression?”
A unit of work the once worked but now doesn’t
Control flow code
any piece of code that has logic in it (loop, switch, etc.) You don’t need to test code without logic
How do you set up a simple unit test without a framework?
1) Create the test class
2) Invoke the class to be tested (Parser p = new Parset();)
3) Check the returned value
4) Invoke the test class by adding a Main as a test runner. You can add more method calls to this class
TDD technique (3 steps)
1) write failing test to prove functionality is missing
2) write code to make test pass (simple as possible)
3) refactor