I have a test project which uses MSTest. And I have a testsettings file and have a properties in that file. as below.
<?xml version="1.0" encoding="UTF-8"?>
<TestSettings name="local" id="77572268-dd99-4f8c-a660-f5c8c1eec977" 
              xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
  <Description>These are default test settings for a local test run.</Description>
  <Execution>
    <TestTypeSpecific>
      <UnitTestRunConfig testTypeId="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b">
        <AssemblyResolution>
          <TestDirectory useLoadContext="true" />
        </AssemblyResolution>
      </UnitTestRunConfig>
    </TestTypeSpecific>
    <AgentRule name="Execution Agents">
    </AgentRule>
  </Execution>
  <Properties >
    <Property name="AAA" value="val1"></Property>
    <Property name="BBB" value="val2"></Property>
  </Properties>
</TestSettings>
But how can I access these properties in testsettings file values by name in runtime. How can I do that?
This is what currently I'am trying..
   [ClassInitialize]
    public static void TestClassInitialize(TestContext context)
    {
        var sad = context.Properties["AAA"].ToString();
    }
And it gives following exception
An exception of type 'System.NullReferenceException' occurred in TestAutomation.dll but was not handled in user code
Additional information: Object reference not set to an instance of an object.
And this is not about the System.NullReferenceException and this is about how to access a property in a Test settings file in runtime. So this question is not a duplicate.
 
     
     
    
