testcontext

Understanding the MSTest TestContext

吃可爱长大的小学妹 提交于 2019-12-18 11:44:41
问题 Using MSTest, I needed to obtain the name of the current test from within the [TestInitialize] method. You can get this from the TestContext.TestName property. I found an unexpected difference in behaviour between a static TestContext that is passed in to the [ClassInitialize] method and one that is declared as a public property (and gets set by the test runner). Consider the following code: using System; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace TestContext.Tests {

Is there anything like Spring TestExecutionListener for TestSuite?

我的未来我决定 提交于 2019-12-12 03:48:01
问题 Currently for tests I'm using TestExecutionListener and it works just perfect public class ExecutionManager extends AbstractTestExecutionListener { @Override public void beforeTestClass(TestContext testContext) throws Exception { System.out.println("beforeClass"); } @Override public void afterTestClass(TestContext testContext) throws Exception { System.out.println("afterClass"); } } Test classes: @RunWith(SpringJUnit4ClassRunner.class) @TestExecutionListeners(ExecutionManager.class) public

c# - selenium - MSTest - Unable to add a result file ( using testcontext.AddResultFile ) to the report using testcontext

爱⌒轻易说出口 提交于 2019-12-11 13:46:16
问题 I am using MSTest - C# - Selenium to run a suite of tests. I am taking a screenshot if there is a failed step and wish to upload ( attach ) it with the trx file, All is good when I run it as a single test of a couple of tests and the results are with the attachment. But when I run the tests in Parallel, I am not able to see the result file with the attachment even though the test is FAILED I get the below in the trx file TestContext Messages: Value cannot be null. Parameter name: path The

How to read test run settings parameter value in specflow tests?

做~自己de王妃 提交于 2019-12-02 15:51:11
问题 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

How to read test run settings parameter value in specflow tests?

我怕爱的太早我们不能终老 提交于 2019-12-02 07:30:16
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

Understanding the MSTest TestContext

China☆狼群 提交于 2019-11-30 04:46:16
Using MSTest, I needed to obtain the name of the current test from within the [TestInitialize] method. You can get this from the TestContext.TestName property. I found an unexpected difference in behaviour between a static TestContext that is passed in to the [ClassInitialize] method and one that is declared as a public property (and gets set by the test runner). Consider the following code: using System; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace TestContext.Tests { [TestClass] public class UnitTest1 { public TestContext TestContext { get; set; } private static TestContext