I am trying to load test a webservice endpoint. I had a data driven unit test built for testing it. My data source is a CSV file and the unit test picks it up and runs smoothly. But when I hook the test to Microsoft Visual Studio LoadTestFramework it is not able to pull the data from CSV file.
My unit test is the one like below:
[TestMethod]
[DeploymentItem("MyProject\\testdata.csv")]
[DataSource("Microsoft.VisualStudio.TestTools.DataSource.CSV","|DataDirectory|\\MyProject\\testdata.csv", "iq3#csv", DataAccessMethod.Sequential)]
public void DataDrivenWebApiTest()
{
var username = (string)Context.DataRow["Username"];
var password = (string)Context.DataRow["Password"];
var token = GetToken(username, password);
var task = RequestClient.GetRequest("/api/endpoint", ApiUrl, token);
var result = task.Result;
result.EnsureSuccessStatusCode();
}
The above unit test is running good in isolation but when hooked to Visual studio load test framework it throws NullPointerException at line 6 i.e "(string)Context.DataRow["Username"];" it says object reference set to null. Can someone please help