Varol Cagdas Tok

Personal notes and articles.

Regression Testing

Software changes. Programmers fix bugs, add features, and refactor code. Every change risks breaking existing behavior.

Regression testing retests functionality after a change to provide confidence that the new code does not have unexpected side effects.

You could retest all by running your entire test suite after every commit. But as the number of tests grows, this approach becomes impractical and costly.

We use techniques to optimize regression testing. The three approaches are minimization, selection, and prioritization.

1. Test Suite Minimization

* Redundant Test: A test \(t\) is redundant if its removal does not reduce the adequacy of the test suite. For a metric \(m\), \(m(T) = m(T \setminus \{t\})\).

* Essential Test: A test \(t\) is essential if it is the only test that covers a specific test goal (like a branch).

2. Test Selection

1. It traces the paths of both versions simultaneously.

2. If it finds an edge in the original program \(P\) that has been modified or deleted in \(P'\), it adds all tests that covered that edge to the selected test suite \(TS\).

* This algorithm selects all tests that would execute differently due to the code change.

3. Test Prioritization

* Greedy Prioritization: Sort the test suite by a previously computed metric, such as branch coverage. The test that covered the most branches runs first.

* Additional Greedy Prioritization: Prioritize based on new information. The algorithm repeatedly selects the test that covers the most not-yet-covered goals. This ensures the first tests cover a wide breadth of the code.