Agent Wranglers

Test strategy Required

Ship tests in the same change

Every change that adds or changes behaviour includes the tests for it. A bug fix starts with a test that fails before the fix.

How to do it

Write or update the test in the same pull request as the code. For a bug, first write a test that reproduces it and watch it fail. Then fix the code and watch it pass. Reviewers reject changes to behaviour that come without tests.

Example

# Bug: a cart with only free items charged a 5.00 shipping fee
def test_free_cart_has_no_shipping_fee():
    cart = Cart(items=[Item(price=0)])
    assert cart.shipping_fee() == 0
// Bug: a cart with only free items charged a 5.00 shipping fee
test('a free cart has no shipping fee', () => {
  const cart = new Cart([{ price: 0 }]);
  expect(cart.shippingFee()).toBe(0);
});

How to check

In review, revert the code change but keep the test. The new test fails. Restore the code, and it passes.

For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers testing playbook: https://agentwranglers.se/playbook/testing/test-strategy/tests-with-the-change.