07 Unit Testing Part 2 Flashcards
Test-Driven Development (TDD)
A software development process where a unit’s test are written before the unit’s implmentation and guide the unit’s development as the tests are executed repeatedly until they are all succeed.
Refactoring
Process of restructuing existing computer code without changing its external behavior.
Improve nonfunctional attributes of the software.
TDD Process Steps
Red:
- Write new tests
- Verify failure of new tests and success of existing tests.
Green:
- Write Code to implement, modify, or develop the unit.
- Repeat until the tests pass.
Refactor:
- Refactor the code
- Confirm tests pass.
Repeat
Unit Testing
A test that invokes a small, testable unit of work in a software system and then checks a single assumption about the resulting output or behavior.
Form of white box testing, focusing on implementation details.
Uses Coverage criteria as the exit criteria.
Unit Testing Tools
Test Framework
Test Runner
Mocks
Coverage Reporter
Test Framework
Defines the test writing syntax.
Test Runner
- Executes all (or subset) of the system’s unit tests and present,s displays or otherwise output the results.
- Might also spin up mocks, a virtual environment, or any other resources the test require.
- Often a basic tesyt runner is built into the test framework.
Mocks
Provides a “mock” or simulated implementation of each external dependency or resources required by the methods being tested.
May return random, dummy, or cached data.
Coverage Reporter
Determines and provides a report on the test coverage metrics.
Might run independently or during each test executed by a test runner.