locked
Property 'ForcedLegacyMode' in .runsettings file caused nulls in ClassInitialize context.Properities["MyProperty"]... How to fix this ? RRS feed

  • Question

  • I woluld like to add recording my tests in VSTest Runner.

    I have one .testsettings file with enabled test recording and multiple .runsettings files with various custom params.

    My example .runsettings:

    <RunSettings>
      <TestRunParameters>
        <Parameter name="prop1" value="val1" />    
      </TestRunParameters>
      <MSTest>
        <SettingsFile>..\TestSettings1.testsettings</SettingsFile> 
        <ForcedLegacyMode>true</ForcedLegacyMode>
      </MSTest>
    </RunSettings>

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

    I know that when i specify path to .testsettings into .runsettings file I have to add ForcedLegacyMode 'true' too.

    But when this is set, values in TestRunParameters are nulls when I read them in ClassInitialize.

    Any help ?

    Wednesday, March 30, 2016 12:53 PM

Answers

  • Hi Sagra Technology,

    According to your description, I create a sample Unit Test project with a .testsettings file and then assign it in .runsettings file. Then I run my unit test with VSTest runner and everything works fine and I don't get any exception.

    Please check whether you have assign the .runsettings file when you run with VSTest runner. And please check whether do you have add the .runsettings file in Solution folder, not under the project folder.

    If the runsettings file are correct and stored in the correct path, please provide a sample project that has this problem to OneDrive and share the link here. It can help us reproduce your problem in our side.

    Best Regards,
    Weiwei

    • Proposed as answer by Weiwei Cai Tuesday, April 5, 2016 6:53 AM
    • Marked as answer by Weiwei Cai Thursday, April 7, 2016 1:01 AM
    Thursday, March 31, 2016 4:06 AM

All replies

  • Hi Sagra Technology,

    According to your description, I create a sample Unit Test project with a .testsettings file and then assign it in .runsettings file. Then I run my unit test with VSTest runner and everything works fine and I don't get any exception.

    Please check whether you have assign the .runsettings file when you run with VSTest runner. And please check whether do you have add the .runsettings file in Solution folder, not under the project folder.

    If the runsettings file are correct and stored in the correct path, please provide a sample project that has this problem to OneDrive and share the link here. It can help us reproduce your problem in our side.

    Best Regards,
    Weiwei

    • Proposed as answer by Weiwei Cai Tuesday, April 5, 2016 6:53 AM
    • Marked as answer by Weiwei Cai Thursday, April 7, 2016 1:01 AM
    Thursday, March 31, 2016 4:06 AM
  • This is because you have

    <ForcedLegacyMode>true</ForcedLegacyMode>

    This reverts it back to using MSTest, so you cannot get the new features of VSTest

    Wednesday, April 20, 2016 4:41 PM