It’s time again for a learning coffee break, today on software testing! This time, 5 minutes are just enough for a short overview. Take yourself some more time to read all linked articles.
- Do you test composer packages or projects with Travis CI? Include the dependencies in the build matrix! With
composer update --prefer-lowest
you install the oldest possible versions instead of the latest. Both have to work, otherwise your version constraints are wrong. How to set this up: Test lowest, current, and highest possible on Travis - Test doubles, that simulate an exteranal API, should be tested themselves regularly, if their return values still have the same format as the real API. This way, changes in the API are recognized early. Martin Fowler calls this Integration Contract Test
- Apropos test doubles. Instead of using mocking frameworks, it’s often more sensible to work with Fakes, i.e. dummy implementations of the interfaces, with own logic but without external dependencies. An example would be an “InMemoryMailer”, which does not send mails but saves them internally and provides test methods for inspection, like”sentEmails()” or “hasEmailBeenSentTo($recipient)”. More on that: Writing Your Own Test Doubles
- Giorgio Sironi explains a raison d’être for “Hello World” programs in Hello world in a production environment, as simple test for development and production environments. Examples: Hello World Unit Test, Ping API, Hello World Microservice.
The idea is, that the “Hello World” code itself is almost guaranteed bug free. This makes it a great candidate to test boilerplate code and environments.