How Do You Test Your Tests

Software today has shifted far from the monoliths of the past towards microservices. Microservices have many benefits over monoliths. They are more flexible, scalable and generally enable developers to add features more quickly. Unfortunately, testing cloud platform microservices is more complicated than it was in the monolithic ancestors. 

For cloud services, functional, integration, and unit tests are performed by creating a lower-level version of your function and plugging in inputs. The outputs from the function can show how your logic and infrastructure performed during the test. 

Clean Unit Testing

It's easy to write "unit tests" that use JUnit and some mocking library.  They may produce code coverage that keep some stakeholders happy, even though the tests may not even be unit tests and the test may provide questionable value.  It can also be very easy to write unit tests that are (in theory) units test but are far more complex than the underlying code and hence just add to the total software entropy.

This particular type of software entropy has the unpleasant characteristic of making it even harder for the underlying software to be restructured or to surface new requirements. It is like the test has a negative value.

The Anatomy of Good Unit Testing

I think of unit tests as an extension to my code. A thorough testing process offers peace of mind that when refactoring the code or making performance improvements, the units still function as expected. It can also find bugs and edge cases and avoid regressions during refactoring.

I come from a.NET / C# background and have compiled this collection of thoughts and tidbits that I find useful when writing tests.