Integration testing

The final type of testing we will demonstrate in this chapter is integration testing. This will use the higher-level methods of our library to ensure that related methods can successfully work together (though the level won't be so high as to have us start our server or make http requests).

One kind of integration test we could do is to check the relation between the Set and Get methods. If we start with nothing, we would expect that we can't Get a key until it is been Set, and that once Set, it can be retrieved. We can even throw in Delete, to then make sure that removes the expected key.

All in all, we will want to run these steps in order and make sure they do what we expect:

  1. Get "key", expect no result

  2. Set "key"

  3. Get "key" again, expect a result

  4. Delete "key"

  5. Get "key" a final time, expect no result

 

This page is a preview of Reliable Webservers with Go

No discussions yet