Skip to content

Instantly share code, notes, and snippets.

@hjwp
Last active December 23, 2015 06:19
Show Gist options
  • Save hjwp/6593604 to your computer and use it in GitHub Desktop.
Save hjwp/6593604 to your computer and use it in GitHub Desktop.
Pros and cons of "fast" and "slow" unit tests

Fast and slow is really a misnomer. We're really talking about "pure" unit tests, which are highly isolated from each other, and will require the use of mocks (unless the code follows a functional paradigm), or "impure" unit tests, which involve more dependencies.

        <td>
            Slower tests may discourage good tdd practice, refactoring etc.
            
        </td>
    </tr>
</tbody>
mocky/isolated tests Non-mocky/ high-dependency / integratey tests
speed fast slower
bugs only specific tests fail many tests fail
readability Often less readable can be overly verbose
risk factors
  • May end up comparing mocks with mocks, and losing link to reality. Need to remember to write integration tests, to check that all units are glued together correctly.
  • More danger of testing implementation rather than behaviour
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment