Skip to content

· 1 min read

JUnit Template For Tracking Bugs in Unit Tests

Placeholder

JUnit Template For Tracking Bugs in Unit Tests

It’s important to track bugs in tests.

  1. Reproducing bugs in tests means the exact scenario gets clear
  2. Once the bug is fixed, we know it will be fixed for life if the test is also part of the build.

This is the template I use to track bugs in tests.

    @Nested
    @DisplayName("$BugCardId$: Bug Description")
    class BugBugNameTest{

        static final String validInput = """

        """;

        @Test
        @DisplayName("SHOULD {assertion description}")
        void {AssertionDescription}Test(){
            // GIVEN
                {code for setting conditions described in WHEN block}

            // WHEN
                {code for running actions}

            // THEN
                {code for assertions}
        }
    }

BugCardId - The Work Item created for the bug. Bug Description - A short one-liner which describes the bug. This should be as clear as possible and focus on the bug rather than something wage.

For example:

  • Message consumer failing on valid input

is better than

  • some problems on dev.

Get new posts by email

No spam. Unsubscribe anytime. Or grab the RSS feed.

Mailto-based for now. ButtonDown / ConvertKit can replace this form later.


Comments lazy-load on scroll. Prefer GitHub? Giscus activates once PUBLIC_GISCUS_* env vars are set (see Giscus.astro).

Index

Index

Back to Blog