2

I checked almost all stack overflow and Microsoft documentation on how to read parameters from .runsettings file in MSTest and tried all the approaches but none worked for me.

I am using .NETCore 2.2, VS 2019, Selenium, SpecFlow+ Runner.

Does not Work with SpecRun.SpecFlow nuget Package but works with SpecFlow.MStest nuget package.

I tried to use it as mentioned here:

  1. How to read test run settings parameter value in specflow tests?
  2. https://learn.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file?view=vs-2019
  3. How to access TestRunParameters within RunSettings file

None of them worked for me.

.runsettings file:

`

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
    <TestRunParameters>
    <Parameter name="appUrl" value="http://example.com" />
  </TestRunParameters>
</RunSettings>

I tried to get "appUrl":

public TestContext context {get;set;};

 [ClassInitialize]
    public static void TestClassinitialize(TestContext context)
    {
      var webAppUrl = context.Properties["appUrl"].ToString();
    }

I tried [AssemblyIntilize] / [TestInitialize] as well.

I don't know if MSTest supports this with SpecFlow+ Runner. Please help.

PLEASE HELP

Ken White
  • 123,280
  • 14
  • 225
  • 444
born2Learn
  • 1,253
  • 5
  • 14
  • 25
  • I edited your title editt. It's inappropriate and unnecessary to add REOPENED to the title. It's clear it got reopened because it no longer says [ON HOLD] or [CLOSED]. Please don't add noise and clutter that isn't needed. – Ken White Aug 13 '19 at 14:27

1 Answers1

0

It's an Open Issue:

https://github.com/techtalk/SpecFlow/issues/817

Have to wait.

born2Learn
  • 1,253
  • 5
  • 14
  • 25
  • 1
    Correct. MSTest's RunSettings parameters (and other MSTest values) can only be accessed within classes or methods that are decorated with the `TestClass` or `TestMethod` attributes. – natn2323 Aug 12 '19 at 18:51
  • @natn2323 - It is not working when I am using `SpecRun.SpecFlow nuget package` as mentioned here: `https://specflow.org/getting-started/` – born2Learn Aug 13 '19 at 14:11