What Makes Good Unit Test? Maintainability
How maintainability can make good unit tests.
In this post I’m going to talk about how we can write more maintainable unit tests.
How maintainability can make good unit tests.
In this post I’m going to talk about how we can write more maintainable unit tests.
How reliability can make good unit tests.
A unit test verifies if the system under test is working the way it should, but how can we trust the test?
Dealing with nulls in the code using the optional type.
Functional programming uses the option type widely, in languages such as Haskell, F#, Scala and a lot more. In this language it’s a convention to return a value when the function fails. The following example is a function written in F#, to show how the option type works:
A better way to deal with nulls in the code.
In programming null is an awkward thing to deal with, when you return a variable with null value, you have to remember to make null checks all around your code.
A clean way to information from appsetting.json file.
Have a time sensitive application? It can affect unit tests outcomes.
When you start to write unit tests, inevitably you’ll encounter a hard time when a functionality depends on time. Depend on DateTime.Now doesn’t work well for unit testing, your tests will pass on certain time of day and fail in others.
What is the best way to create the system under test?
SUT factory may be a fancy name to what is basically a utility method, used to create an instance of the system under test. The main point of a SUT Factory is to reduce code duplication and improve maintainability of your unit tests suite.
In my last post I talked about stubs and how to you can use them to isolate external dependencies in your unit tests. In this post I want to talk about another type of test double, Mock Objects.
Do you know are stubs are?
The definition of stubs can cause confusion sometimes. There are many definitions that you can find in a lot of places, stubs and mock definitions can be pretty similar sometimes, and have a good understanding of both can make the difference when writing highly maintainable unit tests.
Naming your unit tests in the right way.
Naming classes, methods, variables are hard, perhaps one of the most difficult things in programming.