In Step 3 we made one test pass, with one line in our Dockerfile.
Now its a matter of repeating the loop:
- Implement a
pending
test; - Execute tests and it fails;
- Write further instructions in your
Dockerfile
; - Execute tests and it passes;
- Repeat
Take a look at the file specs/Dockerfile_specs.rb
for the full suite of implemented tests.
See Dockerfile
.
The Dockerfile_specs.rb
is definitely not in an optimal state. You can refactor it as needed, all the time following the above loop.
My journey to making tests pass looked something like this:
1 Passed, 1 Failed, 3 Pending
2 Passed, 3 Pending
2 Passed, 1 Failed, 2 Pending
3 Passed, 2 Pending
Nearly There! 4 Passed, 1 Pending!
All Passed! ✔️ ✔️ ✔️ ✔️ ✔️
- Open the
Dockerfile_spec.rb
in this directory. - Look at the helper method
java_version
. It returns thestderr
of the commandjava -version
, not thestdout
. Why is this? - The answer is in this Github issue discussion.
- Long story short:
java -version
output is sent tostderr
. This has been known since the year 2000 and likely will never change.
During the testing process, our tested Docker image has been created, savishy/tomcat-petclinic-tdd
.
Run a container off the image:
docker run -p 8080:8080 savishy/tomcat-petclinic-tdd
Open http://localhost:8080
in a browser.
Certainly this is not "the end" of our TDD journey.
- Can you figure out how to develop tests for the running container?
- More tests can certainly be added - for example:
- to verify the application port
- to verify the image layer counts etc.
- And the
spec/Dockerfile.rb
file is not optimal. How would you peel out the helpers into a separate directory?
Go figure it out!