Growing Object-Oriented Software, Guided By Tests (chapter 11) ❤️
Feb 14, 22We are learning how to set up the end to end tests.
Seems like this is Java-specific, but will try to translate as best as possible.
They are creating a test rig, that will interface with our new app to create accounts and call actions.
To begin with, they will run this server manually - however, this will need to be automated so we can test when deploying the app.
The authors are building a desktop app, so they are using OpenFire
to test drive the GUI programmatically. With regards to web development, there seem to be strong parallels with browser automation libraries such as selenium, cypress, capybara etc
There is quite a lot of code in this chapter that is specific to the app that the authors are building. However, we could perhaps imagine that we are testing a rails/golang application from end-to-end.
For example, an end-to-end test of a web application could look something like this:
- spin up a server
- create an account as a user
- check an email was sent
- click on the redirect link
- check the account was validated as active
- log in as the user
The authors make note that before we start trying to make the above test pass we should have an automated build/deploy pipeline in place so we can easily move from our dev to production environment.
We should only start coding once we have an automated test system in place (we want that juicy feedback as we implement our feature).
If we are using rails, the test harness is baked into the framework. We would need to do a little more digging for Go, but I believe some form of container (that has a test database and dependencies) that can be spun up, and torn down would be sufficient.
We should remember that at this stage we should be testing the absolute minimum. This is the very first piece of the puzzle and is a validation of all the research we did in iteration 0
.
We can expect to do a lot of work getting this stage operational. Although we will have researched libraries that we need for our app, this is where we begin the implementation. So we can expect some debugging, and reading of documentation to get the ‘walking skeleton’ walking!
Edd’s note - I think the chapters where the authors implement the code are helpful, but a little hard to follow. I will do my best to summarize the concepts they introduce in a language-agnostic way.