A harness runs 40 test cases against a file parser. Each test needs a temporary directory of sample files: creating it takes 1.5 s and deleting it takes 0.5 s. Each test body takes 0.10 s. Assume the tests leave the sample files unchanged, so sharing the directory requires no restoration between tests. Compute the total run time when the directory is created and deleted around every test, the total run time when one directory is shared by the whole run, and the time saved by sharing. Give each answer in seconds to one decimal place.
Unlock full course notes by signing up
Choosing a discriminating harness self-check
A harness self-check exercises a test harness using implementations whose behaviour you already know. You want to check whether your harness actually compares returned integers with expected integers.
The required function returns the square of its integer input. Your deliberately incorrect implementation instead returns twice its input:
Assume the harness calculates the expected square correctly and should report pass exactly when the returned and expected integers are equal.
Applying a harness tolerance at its boundary
A test harness checks a sensor-conversion function that returns temperatures in degrees Celsius. Its absolute error is the magnitude of the difference between the returned temperature and the expected temperature:
The harness reports pass when e≤0.10 ∘Ce \leq 0.10\ ^\circ\text{C}e≤0.10 ∘C and fail otherwise. Treat the recorded decimal values as exact for this exercise.
Fitting a harness into a time budget
A continuous-integration job gives a test harness a 60.0 s time budget. The harness has a one-time session startup of 2.4 s, which launches the interpreter and loads a stub server; assume session shutdown takes negligible time. Every test then uses a per-test fixture with setup 0.35 s and teardown 0.10 s, and each test body takes 0.07 s. What is the largest number of test cases that can finish within the budget? Answer as a whole number.
Reconciling retries and duplicate harness records
A test harness plans eight cases with identifiers A through H. Retries and duplicate message delivery can produce several records for one case. The harness processes the records below in row order.
An accepted record is the first record for a planned case that satisfies all three requirements: setup succeeded, an output comparison was produced, and cleanup succeeded. The reporting rules are:
Discard records for identifiers outside A through H.