Carsten Windler
Global Head of Software Development, HolidayPirates Group
UI
Integration / Component
Unit Tests
E2E Tests
Unit Tests
Functional and Integration Tests
aka Acceptance Tests
+ tests the whole application
+ fully supports JavaScript
+ no refactoring or code knowledge required
- slow
- fragile
- require test mode
close to E2E tests, except that no web server and browser is needed
a request is created and thrown at the code (figuratively)
+ great for testing REST APIs
+ no JavaScript
+ fast (compared to E2E tests)
+ quite robust
- require test mode
like Unit Tests, but not ran in isolation (e.g. using "real" databases)
dependencies are not mocked
+ slower as Unit Tests, but fast enough
+ reveal problems early
- require test mode
tests must reliable and reproducable
tests should be fast / as fast as possible
problematic if your app deals with any external data source (e.g. databases, 3rd party APIs)
you need to prepare test fixtures
setup a test environment which is only using these fixtures
=> put your app into test mode
for web apps, you would specify a certain test URL (testing.myapp.local) on your local or on the test environment under which the app only uses the prepared fixtures
initial test mode setup can be quite some effort for legacy projects (e.g. creating database seeders and migrations)
however it allows you to write E2E and functional and tests without modifying the code itself
Reference
Test run
Comparison
Tests needed for 100%
Code Coverage
Tests needed for bug-free code
Example: Infection for PHP
You might ask yourself now:
"An MSI of 78% sounds ok-ish, but what exactly can I do with this information now?"
Arguing about code quality is easier when you have objective standards
REFACTORING TIME!!
(* ideally, but for hotfixes you should be able to surpass this)
fast running tasks on pre-commit hook
(* only on changed files)
=> save CI resources (and save developer time) by running these steps locally before code can be committed
run all the tests!
* will not break the build, but issue warnings
more options
Continuous testing is not only about running automated tests
Carsten Windler
https://www.pexels.com/photo/adult-dark-depressed-face-262218/
https://www.pexels.com/photo/man-person-relaxation-steps-4129/
https://www.pexels.com/photo/adventure-attraction-blur-calm-618545/
https://www.pexels.com/photo/biotechnology-bright-chemical-chemistry-207585/
https://www.pexels.com/photo/woman-reading-a-book-256546/
Image credits