Do you reference the issue ID when writing a test to confirm a bugfix?

Updated by Steven Qiang [SSW] 2 years ago. See history

123
<introEmbed body={<> Some bugs have a whole history related to them and, when we fix them, we don't want to lose the rationale for the test. By adding a comment to the test that references the bug ID, future developers can see why a test is testing a particular behaviour. </>} />
[Test]
public void TestProj11()
{
}

❌ Figure: Figure: Bad example - The test name is the bug ID and it's unclear what it is meant to test

///
Test case where a user can cause an application exception on the
Seminars webpage
1. User enters a title for the seminar
2. Saves the item
3. Presses the back button
4. Chooses to resave the item
See: https://server/jira/browse/PROJ-11
///
[Test]
public void TestResavingAfterPressingBackShouldntBreak()
{
}

✅ Figure: Figure: Good example - The test name is clearer, good comments for the unit test give a little context, and there is a link to the original bug report

Acknowledgements

Adam Cogan
Related rules

Need help?

SSW Consulting has over 30 years of experience developing awesome software solutions.

We open source.Loving SSW Rules? Star us on GitHub. Star