开发者

How to choose between different formats for storing data for tests?

Similar to What is the best format to store test data in a file? I want make some tests with data in my class.

This class must receive a list of data with date and value. So basically, I just need to store values and when I read I can say the initial date and just add a constant to get next co开发者_StackOverflow社区rrespondent date - value. Something like: 1234.56;6543.21;1111.22

I'm using csv right now, but I'm wondering if some xml, sqlite or pure IEnumerable in C# will be a better option. Some experience about this?


With the requirements you have communicated, the answer is whatever is easiest. If you are talking numeric data so you don't have to worry about quoted strings and the like, CSV seems quite reasonable.


Choose the simplest thing that works and is maintainable. In order of preference

  • If you your data is relatively simple (as depicted in the question), you could do it in-memory within the test-fixture class. Use factory methods / types to get the expected Data.
  • If you want structured data that is easy to read/edit, use CSV (everyone knows how to use Excel) or YAML (another text-based format) or a custom text file.
  • On the other hand, if you need structured schema-valid data, then you could choose something like XML or canned test-databases.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜