I am trying to run mstest from command line. When I run this with command line, I get the below error.
Test has invalid DataSource attribute. Either DataSourceSettingName or ConnectionString and TableName must be specified and cannot be empty.
0/1 test(s) Passed, 1 Not Runnable
This is a data driven test and the who test is run multiple times using the data in the spreadsheet.
Surprisingly, when I run it from Visual Studio IDE, I am able to run the test and able to get the results. Its only from command line I am facing this issue.
Below is how my test is looking
[TestMethod]
[TestCategory("APITests")]
[DataSource("System.Data.Odbc",
"Dsn=Excel Files;" +
"Driver={Microsoft Excel Driver (*.xls)};" +
"dbq=|DataDirectory|\\APITestData.xls;" +
"defaultdir=.;" +
"driverid=790;" +
"maxbuffersize=2048;" +
"pagetimeout=5;" +
"readonly=true",
"APITestData$",
DataAccessMethod.Sequential)]
[DeploymentItem("APITestData.xls")]
public void PostAndValidateAPITests()
{
//UNIT TEST CASE CODE
}
Any help would be deeply appreciated to run the test in command line.
have you tried to add parameters to your test acccording to your datasource ? I think there is 5 parameters in your test method descriptor :
[TestMethod]
[TestCategory("APITests")]
[DataSource("System.Data.Odbc",
"Dsn=Excel Files;" +
"Driver={Microsoft Excel Driver (*.xls)};" +
"dbq=|DataDirectory|\\APITestData.xls;" +
"defaultdir=.;" +
"driverid=790;" +
"maxbuffersize=2048;" +
"pagetimeout=5;" +
"readonly=true",
"APITestData$",
DataAccessMethod.Sequential)]
[DeploymentItem("APITestData.xls")]
public void PostAndValidateAPITests(var Odbc, var param, var isReadonly, var API, var accessMethod)
{
//UNIT TEST CASE CODE
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.