-
Book Overview & Buying
-
Table Of Contents
Rust Web Programming - Third Edition
By :
In this chapter, we built unit tests and mocks. We then configured our mocks to pass in a range of different outcomes to see how our code behaves under a range of different edge cases. Think back to when you were developing the application throughout the book. You would have to spin up the server and configure a range of requests to get to the piece of code you wanted to test, then manually perform the test that you wanted. This is very time-consuming, especially if you want to test your endpoint for a range of different conditions. Our unit tests not only give us feedback within seconds from an automated process, but they are also baked in, meaning that we can run one command to run all our tests within seconds whenever we change any of the code.
Speeding up the feedback on how our code runs will always result in faster development time. This is why good, experienced developers practice test-driven development. This is where we write the tests as we are writing the code...