Let’s Get Certified
Module 06 / 07 · Developer productivity

Verify tests, refactors and performance claims

Use Copilot to propose examples, refactors and documentation. Verify behavior and measure any claimed speed change on inputs that resemble the intended workload.

Write the expected value independently

A courier bills one additional unit for each started kilogram. Write a small table before asking Copilot for a refactor. If weights are integer grams, the extra unit starts at 1,001 grams. Inputs 1, 999, 1,000 and 1,001 should produce 1, 1, 1 and 2. Require the candidate and the original to pass the same contract. Compare outputs before timing the two implementations.

A unit test isolates the rounding calculation. An integration test submits an order through the real application interface and checks the value actually stored on an invoice. Use synthetic orders in a disposable database. Ask Copilot for edge cases or a first draft of documentation, then trace each assertion or example to a supported behavior. For performance claims, measure the same input distribution and environment before and after the edit.

For the courier example, record the expected charge on paper before asking for test code. Next, deliberately replace the ceiling calculation with integer division. If the suite still passes, find the uncovered boundary. Put that fixture in the test suite as a regression for the specific failure.

Worked case 1

A generated test asserts that the billing function returned an integer. It passes when the function always returns one.

Check your reasoning

Add an independent expected value on each side of the threshold. Include 1,001 grams to distinguish the broken implementation. Choose the zero-weight rule with the product owner before encoding it in the suite.

Worked case 2

A team wants to replace a legacy parser and publish its new usage instructions.

Check your reasoning

Capture representative old outputs first. Compare the replacement on ordinary and malformed inputs, decide which differences are intentional and run the documentation examples against the shipping version.

Catch a billing regression

Run this self-contained Python 3 example. Both formulas look plausible. Predict which input first distinguishes them, then compare the results with the written expectation. The contract covers positive whole grams.

def started_kilograms(grams):
    return (grams + 999) // 1000

def rounded_down(grams):
    return max(1, grams // 1000)

cases = [(1, 1), (999, 1), (1000, 1), (1001, 2)]
for grams, expected in cases:
    assert started_kilograms(grams) == expected
    if rounded_down(grams) != expected:
        print(grams, expected, rounded_down(grams))
Check your output

The output is 1001 2 1. Add 2001 grams and derive its expected value without calling either function. It should produce a second mismatch, 2001 3 2.

GitHub documentation · GH-300 skills outline

Related lesson in GitHub Actions. Find the first failing job and reproduce its inputs.

Practice with the recording

Generated tests pass even when the implementation returns a constant. What would make the suite discriminate between behaviors?

Check your reasoning

Add a second input with a different expected outcome and a failure-path assertion. Run the tests against a deliberately incorrect local implementation, then restore the intended behavior. Review what the assertions prove independently of coverage percentage.

Current GH-300 course · 1:02:18 · Lionel Gurret · GH-300 Study Cram · 19:54

Modernizing a dependency

Capture observable behavior with fixtures before asking for a refactor. Use generated test data where it covers the real boundary conditions and exclude customer records. Run both unit and integration checks and measure the performance claim separately.

Knowledge check

Verify tests, refactors and performance claims quiz

Answer 3 questions. Check each answer for an explanation.

Worked example · A fixture that hides a regression