How to execute a line of code which is a data setup code in MSTest before all test

ساخت وبلاگ

Vote count: 0

I have a very uncommon scenario. I have a function, lets call this as DataGenerator. This method generates all test XMLs which are needed for the tests to execute. These XMLs are referenced as data source in each of the MSTests.

 [TestMethod] [TestCategory("UITest"), TestCategory("PersonalDetailsFlow")] [DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\TestFlows.xml", "flow", DataAccessMethod.Sequential)] public void TestMethod1() { //Test Code } 

And I use the below code to create test XMLs

 [ClassInitialize] public static void ClassInit(TestContext context) { DriverData driverData = new DriverData(); driverData.DataGenerator(); }

When I run this code, I get the below error line The unit test adapter failed to connect to the data source or to read the data. For more information on troubleshooting this error, see "Troubleshooting Data-Driven Unit Tests"

I believe this is because MSTEST is looking for TestFlow.xml in |DataDirectory||

Can anyone please help me how to execute the code

DriverData driverData = new DriverData();
driverData.DataGenerator();

before any of the code gets executed so that I can avoid the above message. Any pointers would be really great

asked 1 min ago

back soft...
ما را در سایت back soft دنبال می کنید

برچسب : نویسنده : استخدام کار backsoft بازدید : 154 تاريخ : جمعه 21 خرداد 1395 ساعت: 12:22