开发者

VS Team: A concrete example of the use of the TestContext property using Microsoft Unit Testing Framework?

While writing my tests this week for a new project, I encountered the TestContext property using the Microsoft Unit Testing Framework available with Visual Studio Team System.

I was wondering:

1. How this property could be used concretely?

2. In other words, what is开发者_运维技巧 its purpose?

3. Anyone has a concrete example to provide to ease my understanding?

I have written many tests so far in my career, and have never ever found a use for this particular property.

Any clue anyone?

Thanks in advance! =)


This property can be used to run parametrized tests, like if you have constants you don't want to hardcode in your test project that you want to load and share among all the tests. By default it will be populated with useful information, like the path where your test is running.

Then it is one of the key to run the same test several times with different values. The MSTest framework can be used to link your test project to a database or a csv file and run the tests once for all the rows in the said DB. This is called data driven testing and you'll find many sample on the net. Here is one how to.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜