Unit tests — Playing chess against yourself

Playing both sides

Writing unit tests

Good naming convention

  • name of unit that need to be tested
  • conditions under which you are testing that unit
  • expected result
CalculateDiscount_ByPercentageForValue1000_Return100
CalculationDiscount_should_return_100_for_ByPercentage_when_price_is_1000

What not to cover with unit tests

Failed unit tests are friends, not the enemy

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Krste Šižgorić

Krste Šižgorić

Full stack Software Engineer and Team Lead at TravelSoft, focused on system architecture and creating reusable software.