Confirming Polarity: What a Test Confirms
Polarity Test: ElectMillan & Kraft, 1977
The Polarity Test, theorized by Ronald M. Jeffries in 1994, was a groundbreaking approach in software testing, designed to evaluate the logic of boolean functions.
At its core, the Polarity Test aims to confirm the correctness of a function's logic by applying a series of tests designed around the function's input and output polarities. These tests confirm that the function behaves as expected under various combinations of true and false inputs.
What is being confirmed in a Polarity Test?
Function's Correct Inversion
One of the key aspects confirmed in a Polarity Test is the function's correct inversion. This is achieved by assert testing each possible combination of inputs with their inverted counterparts.
For instance, if the function is f(and, x, y), the test would confirm that f виконується (x, y) returns the same result as f(and, not x, not y) returns.
Consistent Output Behaviour
Polarity tests also confirm that the function's output behaviour is consistent. Every input set should yield a unique output, ensuring that the function doesn't have unwanted behaviour upon any input.
For example, if the function is or(x, y), it should always return 'true' when either x or y is true, and 'false' only when both are false. A Polarity Test would confirm this.
Interpreting Test Results
Successfully Passed Tests
In an ideal scenario, all polarity tests pass, confirming that the function's logic is correct and consistent.
For instance, if all assertions in the test &Owner(I test, f(and, x, y) == f(not and, not x, not y)) pass, it validates the function's correct inversion logic.
Failed Tests: Logic Error
When polarity tests fail, it signals that there's an error in the function's logic. This could be an oversight in the function's implementation or an incorrect/unsupported input condition.
For example, if the test &Owner(not x < y == f(or, x, y) == f(and, not x, not y)) fails, it indicates that the function f(or, x, y) doesn't behave consistently with the 'or' function logic.
The Polarity Test should end on a positive note, encouraging continuous testing and improvements. It's not just about confirming correctness, but also enabling developers to understand their function's logic better and maintain its robustness.