Poll: How do you approach testing at work?
There's a lot of debate around testing. I'm interested to see how people approach it at work and how satisfied they are with their approach.
To preempt arguments about terminology, here's how I'll define the terms for the purposes of this thread. If the test doesn't touch any external service, it's a unit test, even if it executes thousands of lines of code. If it runs against a real Postgres instance or a real filesystem, it's an integration test. If the test is done entirely through the program's UI and public APIs, then it's an end-to-end test.
- 1 point
We have few or no tests and we're fine with that
- 1 point
We have few or no tests but we'd like to change that
- 1 point
We focus on unit tests and do a lot of mocking
- 1 point
We focus on unit tests but try to avoid mocking
- 1 point
We focus on integration tests that aren't end-to-end
- 1 point
We focus on end-to-end tests
Comments
I think my testing is pretty standard. Both in approach and amount.
But I’ve been more focused on integration tests lately as part of my development cycle. First unit tests for the small things like the mappings we tend to do so much of. Then the integration tests as a key part of my actual development. And then lastly I incorporate it into my application without much worry. Using this code in the application is now the least of my work because I already know all of the processes already work as expected. It’s just a matter of wiring it up correctly.
Unit tests are unit tests. But the part you may be interested in is that integration test for me lately have been very much literally “how I develop”. I encapsulate units of whatever process is at hand this push into my test. I might ingest documents from db, file, or api, and examine them with the debugger and see what I have available, what work that needs to be done elsewhere. Move forward and maybe use all of the mappings I mentioned (already unit tested), manipulate / transform / lookup (already unit tested). Move forward and examine the results of the ingest /export / process from whatever service is providing that feature.
I consider my integration tests to be anything that performs multiple actions for components that are already unit tested, maybe can handle an expected exception, maybe requires another component of the app to be running.
It’s definitely not TDD. But if it’s something QA is gonna analyze with excel or some validator api then it’s been unit tested. If it’s a process I want robustness out of, it’s been integration tested.
I think the switch for me happened when I decided not to create “that little console app” to wrap my work and aid development; and instead just write a test. I’m sure someone might critique the heck out of my thoughts here. But it’s working.
Unit tests for complex logical or algorithmic code with simple interfaces.
Hermetic end to end tests for the rest.