I had two days of laziness with the excuse of busy work. Today, I continue my unit test. We have discussed how to perform a simple unit test. This time we will be familiar with how to perform a data-driven unit test in visual studio.
Before getting started, let's clarify what a data-driven unit test is. Borrow the text in msdn to use the Microsoft unit test framework to host code, you can set the unit test method to retrieve the values to be used in the test method in the data source. It is more convenient to use one method to test each row of different input data sources during continuous operation.
Start now!
1. Prepare the test code. The code to be tested this time is the same as in the previous article.
namespace BigMan.UnitTest{ public class Program { public static int Add(int a, int b) { return a + b; } public static int Div(int a, int b) { return a / b; } static void Main(string[] args) { } }}