Testing CSV Parser and Column Mapping

I am really starting to enjoy unit testing and asking the next question from unit testing gurum.

Suppose, for example, that I have the following class

public class FileMapper
{
   public Dictionary<string, string> ReadFile(string filename, string delimeter){}
}

How do you guys usually go about unit testing the Parser or ReadFile method in my case?

+3
source share
1 answer

Given the method signature you provided, you can simply "unit test the ReadFile method by calling it with many different inputs and confirm the return value is correct.

Obscure Tests, , .

TDD , API.

, , :

public Dictionary<string, string> ReadFile(TextReader reader, string delimeter)

TextReader , StringReader unit test.

unit test ReadFile, , .

+8

Source: https://habr.com/ru/post/1746353/


All Articles