Lena Ebner Logo

Why Writing Tests?

Some might wonder why I should write tests for my code? How can I benefit from it?

The core answer to this is: the earlier you find a bug, the easier you can fix it - the less costs.

Different Testing Strategies

  • Static Analysis: find typos, incorrect function calls, autocompletes your code
  • Unit Tests: simple, small and fast tests that verify that a small piece of your code does what you think it should do
  • Integration Tests: testing of multiple parts of your software playing together e.g. database connection and other services
  • E2E Tests: rather slow automated tests of your software in a production like environment, thinking in terms of stories, does the system function how it should
  • QA Tests: explicit people testing your system in a production like environment to ensure everything works together as expected
  • User Tests: end users will test your system in production and find edge cases you never thought of, tests usability
  • Additional Tests: security, capacity, availability

Why and how to use them?

By applying different testing strategies you can avoid that the end user struggles with your software because of something unexpected in your code.

Furthermore, it strengthens confidence in the function of the software and allows refactoring without unnoticed breaking of existing functionality.

You can automate testing and include it in your CI/CD pipeline to validate that your new code has not broken an existing feature, and only if all tests pass deploy the new version of your system to production.

For each tech stack there are different testing libraries and testing suites available like JUnit, RSpec, Selenium, Playwright, Cypress, Cucumber.