October 2017
Intermediate to advanced
458 pages
11h 13m
English
One of the most important things you can do to guarantee that certain parts of your software produce correct results is by writing unit tests. A unit test is simply a piece of code that calls a method (the method to be tested) with a predefined input and checks whether the result is what you expect it to be. If the result is correct, it reports success, otherwise it reports failure. The unit test, as the name implies, tests small and isolated units of code.
Let's say you write a function int Add(int a, int b) in C# (I'm pretty sure every programmer can follow though):
public static class MyMath
{
public static int Add(int a, int b)
{
return a + b;
}
}
The first thing you want to test is whether Add indeed returns a + b and not ...
Read now
Unlock full access