0
votes

Following code is used to inject data to the unit test from a CSV file.

[DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV", "|DataDirectory|\CalculatePowerInputFraction05.csv", "CalculatePowerInputFraction05#csv", DataAccessMethod.Sequential), DeploymentItem("Simulation.Test\CalculatePowerInputFraction05.csv"), TestMethod]

public void CalculatePowerTest3() { }

I am setting the above properties by

Right Click on the test in test view -> Properties -> Connection String -> Choose CSV file

The problem I am facing is, |DataDirectory| contains absolute path. I am unable to run the tests in any other system. Is there any other way to provide input to TestContext so that problem with absolute path can be solved by giving relative path?

1

1 Answers

0
votes

I have not worked on Visual Studio but in java I would do like this . Store the value of DataDirectory in some properties file and the read the value into your test. On different systems, the value of the properties file can be changed prior to running the test.