locked
MSTest - Unable to run the test using runsettings file RRS feed

  • Question

  • I am having a unit test project and the sample code is below. Basically my plan is to create the test data at run time and this data will act as a datasource for the unit tests.

    [TestMethod]

    [TestCategory("UITest"), TestCategory("PersonalDetailsFlow")]

    [DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\TestFlows.xml", "flow", DataAccessMethod.Sequential)]

    public void TestMethod1()

    {

     //Test Code

    }

     

     

    [ClassInitialize]

    public static void ClassInit(TestContext context)

    {

        DriverData driverData = new DriverData();

        driverData.DataGenerator();

    }

    The data creation happens in the ClassInitialize section. When I set the settings file to a testsettings file, the project runs without any issues.

    When I change the settings file to point to a runsettings file (since I have lot of data passed from runsettings file), 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 am quite curious to know whats happening when I run using testsettings to make it successful but when using a runsettings file, getting all issues and how to avoid this when using a runsettings file.

    Any help on this is much appreciated

    • Moved by DotNet Wang Tuesday, June 14, 2016 1:51 AM move to correct forum
    Monday, June 13, 2016 11:18 PM

Answers

  • Hi Timothy Rajan Alex,

    According to your description, I create a sample Data-driven Unit Test with .testsettings and then change a runsettings file for this Unit Test.

    Please check whether there has any problem in your runsettings file which lead to the Unit Test can't find the data source. I'm using the runsettings content in following link, which can run successful in my side. Please compare your runsettings file content.

    https://msdn.microsoft.com/en-us/library/jj635153.aspx

    In addition, please share your runsettings file to help us understanding what's settings do you set. It can help us reproduce your problem in our side.

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Weiwei Cai Monday, June 20, 2016 9:27 AM
    • Marked as answer by Weiwei Cai Wednesday, June 22, 2016 12:28 AM
    Thursday, June 16, 2016 9:46 AM

All replies

  • Monday, June 13, 2016 11:38 PM
  • Hi Timothy,

    Thank you for your post. Based on your description, your question is more related to Unit Test. We will move your thread to Unit Test forum for better support.

    Best Regards,
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, June 14, 2016 1:50 AM
  • Hi Timothy Rajan Alex,

    According to your description, I create a sample Data-driven Unit Test with .testsettings and then change a runsettings file for this Unit Test.

    Please check whether there has any problem in your runsettings file which lead to the Unit Test can't find the data source. I'm using the runsettings content in following link, which can run successful in my side. Please compare your runsettings file content.

    https://msdn.microsoft.com/en-us/library/jj635153.aspx

    In addition, please share your runsettings file to help us understanding what's settings do you set. It can help us reproduce your problem in our side.

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Proposed as answer by Weiwei Cai Monday, June 20, 2016 9:27 AM
    • Marked as answer by Weiwei Cai Wednesday, June 22, 2016 12:28 AM
    Thursday, June 16, 2016 9:46 AM