How to read parameters from .runsettings file from Visual Studio for specflow tests

2,694 views
Skip to first unread message

Nandakumar Balasubramanian

unread,
Dec 14, 2017, 3:13:04 AM12/14/17
to SpecFlow

We use .runsettings file in visual studio for running specflow tests. There we have certain parameters configured. I need to access those parameter values at run time to use in specflow test methods. I tried accessing those via TestContext as below

 [ClassInitialize]
    public static void Initialize(TestContext testContext)
        {            
            var value= 
            Convert.ToString(testContext.Properties["testParameter1"]);
        }

I am getting the exception for testcontext instance at run time as below. "System.NullReferenceException: 'Object reference not set to an instance of an object.'"

Environment Visual Studio Enterprise 2017 Specflow 2.2.1 Unit Test Provider: MsTest

This code worked fine while using it in the Microsoft Unit Test project. How to read values from Test Run Settings file for specflow tests? Is there any other way to access runsettings parameters?

Andreas Willich

unread,
Dec 15, 2017, 4:18:57 AM12/15/17
to spec...@googlegroups.com
For the others, question is answered on Stack Overflow: https://stackoverflow.com/a/47794335/3155323

--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specflow+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages