This lecture contains information about how we might go about assessing the internal and external quality of a piece of software through software testing.
Internal quality is developer-facing quality.
External quality is customer-facing quality.
If we were to try and create tests for a list in python, what might we test?
- Does it append correctly?
- After appending, does the rest of the list stay the same?
- Does it "pop" correctly?
- After popping, does the length of the list change?
- After popping, what happens when we try to access the most recently removed item?
- This can get complicated really quick.
Software testing is an investigation conducted to provide stakeholders with information about the quality of the software product or service under review.
- Typically, tests involve input data and comparisons with output data.
- Testing gives you confidence that your implementation adheres to your specification.
- We compared provided program's output to expected output.
- We did this by running the program with provided inputs.
An oracle gives us the right answer to a given input.
In this lecture, we will discuss regression testing, system testing, and unit testing.
If a regression is when something "goes backwards", regression testing is testing for regressions in the source code.
A regression test is a test that exposes a particular bug, and is used to ensure that future implementations of the software still fix this bug.
- These are "I swear I saw this and fixed this before" tests.
- When a developer fixes a bug, they can add a regression test that exposes this bug to make sure it stays fixed.
Testing an end-to-end system for correctness is called system testing.
Testing individual chunks of source code to determine that they work is called unit testing.
- A unit might be a function, module, class, etc.
- Unit tests are very common.
- As such, unit test frameworks are very common.
- Junit (Java) and unittest (python) are examples of these frameworks.
- They ensure that unit tests look like other code.
- They provide special functions/methods to return a boolean or certain failure assertions.
A test case discoverer finds all unit tests in the code based on a special naming scheme.
A test case runner chooses which tests to execute.
A test case performs three operations in isolation: (1) establish some precondition, (2) perform an operation, (3) assert postconditions.
A test fixture surrounds a test case to provide code that is run before and after each test case.
- Test fixtures are often used for set up (before) and clean up (after).