Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to create data provider in C#. However, I don't want to connect the DB. I just want to provide some values. Is there TestNG like unit testing framework in C#, which can I use? Is there any way of doing the following in C# - Microsoft Unit tests (The code was taken from

@Test(dataProvider = "Data-Provider-Function")
public void parameterIntTest(TestNGTest6_3_0 clzz) {
   System.out.println("Parameterized Number is : " + clzz.getMsg());
   System.out.println("Parameterized Number is : " + clzz.getNumber());

//This function will provide the patameter data
@DataProvider(name = "Data-Provider-Function")
public Object[][] parameterIntTestProvider() {

    TestNGTest6_3_0 obj = new TestNGTest6_3_0();

    return new Object[][]{
share|improve this question
up vote 1 down vote accepted

The short answer is that yes, you can do this. I don't have the code that will do it to hand, but you will find the basic information at

The Microsoft preferred method is to store the test data in some form of external data source (so that if the data needs to change you don't need to recompile) - the source can be XML, CSV, one of several different database types...

The other method, if your object is mocking something drawn from an actual class in the application in test, is to use the MS fake framework which works in with the unit test framework by allowing you to define fakes and shims to use in place of the real methods (fakes are compile-time, shims are run-time redirects from the real methods - there are other differences as well, but that's the super-short version). gives more detailed information on creating tests where the data is pulled from an external data source. has samples of connection strings for some of the more common data source types.

In addition, the best guide I've seen to using fakes and shims is this Channel9 video: (It's a long one, but well worth it)

(I do not work for Microsoft - I just use their tools)

share|improve this answer
In addition to MSTest (Microsoft's unit testing library) another commonly used and more flexible and extensible solution is NUnit. It allows you to use external data sources or reference properties, functions or lists for your data sources. – Sam Woods Nov 13 '13 at 21:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.