Lecture 7 Flashcards
Unit Testing (UT)
Tests that verify the functionality of individual/specific units of code, usually written by devs as they work on code, to ensure that specific functions are working as expected.
[UT] Benefits
- Find problems early on
- Simplifies Integration and integration testing later
- Provides living documentation of a new system
[UT] Case Structure (and the acronym!)
S.E.V.C
- Setup (put UUT in state needed to run the test)
- Execute (trigger UUT target behavior, capture all output)
- Validation (ensure test results are correct)
- Cleanup (restore UUT to pre-test state to allow for immediate test execution)
[UT] Characteristics
F.R.O.M SLC. FC. C.A.M
- FAST
- READABLE
- ORDER doesn’t matter
- MEMORY-ran
- SINGLE LOGICAL CONCEPT tested
- FULL CONTROL over all running processes
- CONSISTENTLY returns same result
- ABLE to be fully automated
- MAINTAINABLE
[UT] Outcomes
- 1+ assert statements to validate specific outcomes
- Verify that no/a particular exception was (not) thrown
[UT] Substitutes
Unit Test substitutes are used to assist in testing a module in isolation.
- Method Stub: a stand-in piece of code for some programming functionality
- Mock Object: a simulated object that mimics the behavior of real objects in controlled ways
- Test Harness
Integration Testing (IT)
any type of software testing that seeks to verify the interfaces between units or components against a software design.
works to expose defects in the interfaces and interaction between integrated components (aka modules)
IT vs UT
Integration:
- coarse-grained
- complex
- test intricate web of calls
- slow
- can’t run in an IDE
Unit:
- fine-grained
- simple
- test single API call
- fast
- easy to run in an IDE
Test Driven Development (TDD)
Software development process that relies in the repetition of a very short dev cycle
[TDD] Cycle
1) Dev writes an initially failing automated test case, defining a desired improvement or new functionality
2) Dev produces minimum amount of code to pass that test
3) Def refactors the new code to acceptable standards
[TDD] Benefits
- Dev is concerned with the interface before implementation
- Dev focuses on making the test pass ONLY, not exceptional cases, error handling, etc
- Early and frequent testing, obviously
- Code produced is more modularized, flexible
Code/Test Coverage (C/T C)
A measure that describes the degree to which source code of a program is tested by a particular test suite. High code coverage means it’s been thoroughly tested and a lower chance of software bugs.
Tests include: U.A.I.R (unit, automated, integrated, regression)
[C/T C] Types
- Functional
- Statement
- Branch
- Path
[C/T C] Functional Coverage
has each function (subroutine) in the program been called?
[C/T C] Statement Coverage
Minimum number of paths in which all nodes are covered