Questions tagged [testcontext]
38 questions
1
vote
1 answer
How to get a test result output file attachment from remote test agent for mstest
My MSTest creates an artifact the end and attached it to the test output using TestContext.AddResultFile.
If I run the test on my local machine then the attached files are available with test output, but when I run the test on a remote test agent…

SarkarG
- 687
- 1
- 8
- 30
1
vote
1 answer
Read Data into IDataReader from TestContext
This might sound strange but exactly this is what I want to do:
I have a TestMehod Currency_ReadItem_Test() which tests ReadItem() method in Currency class. This ReadItem() takes IDataReader object as an parameter and fills local data members in the…

IFlyHigh
- 546
- 2
- 9
- 20
1
vote
1 answer
testContextInstant value is always Null when it was called from logger file to test case file
I have read some information regarding TestContext of MStest and can use it accordingly.
Now my task about TestContext is a little bit different and am confusing how it could work.
The situation related to three files:
In testcase.cs file,…

user3002661
- 13
- 4
0
votes
0 answers
Visual Studio 2022 mstest .NETcore - Gives no explanation why it won't run unit tests or how to fix the problem
PRoj file
Sdk="Microsoft.NET.Sdk"
"DotNetSeleniumExtras.PageObjects.Core" V="4.3.0" "itext7" V="7.2.5" "Microsoft.Extensions.Configuration" V="7.0.0" "Microsoft.Extensions.Configuration.Json" V="7.0.0" "Microsoft.NET.Test.Sdk" V="17.5.0"…

Madhavi
- 1
- 2
0
votes
0 answers
Using ConfigurationProperties / Constructor binding for immutable kotlin data class with custom spring context
I'm building a custom Spring context for my test in Spring Boot 2.7 (feel free to provide also a solution for newer versions). I'm not able to specify exact list of classes / auto-configuration needed for using ConfigurationProperties (kotlin,…

Robert Gonciarz
- 363
- 2
- 8
- 15
0
votes
1 answer
Cannot access Properties value in MSTest
I'm actually facing an issue using TestContext in MSTest. When I add a property to the context, it doesn't exist when I try to get it in another test method. Can someone explain me why or know how to fix it?
Here is my code sample:
I can't get why i…

invaders7vn
- 37
- 1
- 5
0
votes
0 answers
Visual Studio 2019 - cannot get a TestContext instance in test unit
[admin, this is no duplicate, I haven't found the solution in other related threads, since everybody talks about older VS versions]
I try to get a TestContext in my test unit in VS2019
no matter what I get a NULL reference
I used the code from the…

pf12345678910
- 141
- 6
0
votes
0 answers
Why is @BeforeSuite variable sometimes initialised correctly in test, and other times null?
I'm trying to use the @BeforeSuite annotation in my tests to create some Data that will be used across all tests, therefore I only want to create it once and then be able to access it from all of my tests that run.
I'm seeing an issue where,…

Aimee Jones
- 881
- 2
- 18
- 38
0
votes
0 answers
why do i get AdhocTestMethod name for test in c# selenium
I work with c# and selenium nunit
I decalred test method
and when i want to get the name I get 'AdhocTestMethod'
[TestClass]
public class tryTest : SeleniumTestBase
{
[TestMethod]
public void CreateTaskTest()
{
…

ציפורה נחשון
- 1
- 2
0
votes
0 answers
Reuse test context in micronaut integration tests
I noticed in my Mironaut application integration tests that Micronaut context is started before each test class (annotated with @MicronautTest) and then destroyed after all tests from that class are executed, so the next test class has its own…

mattie
- 1
0
votes
1 answer
Share Test Context in Cucumber,while creating object in java to share same state for all scenarios i am getting exception
Share Test Context in Cucumber,while creating object in java to share same state for all scenarios i am getting exception
here i am creating object of endpoints class from TestContext class
Failure Trace
java.lang.IllegalStateException: Cannot stop.…

Arpit Aggarwal
- 87
- 6
- 18
0
votes
1 answer
How to access TestContext in Specflow 3.0 [BeforeTestRun] static Hook
I have started using Specflow 3.0 for .NET core tests project with built-in MSTest runner.
I encountered problem while trying to setup one-time method execution in order to persist bearer token value for all running tests in Specflow.
So my idea was…

Kasparas Taminskas
- 191
- 2
- 13
0
votes
0 answers
How to get list of selected test case in MSTest with C#
I'm trying to retrieve a list of the selected test to run in ClassInitialize. Can you help with that?
[ClassInitialize]
public void classInitialize()
{
String name=TestContext.CurrentContext.Test.MethodName;
}
Using the above code I'm able to…

Vijaya s
- 31
- 5
0
votes
2 answers
how to get current test method name in any class of project in codedUI?
I want to compare the current test method name, but getting an exception that
TestContext returns null.
public TestContext TestContext { get; set; }
private void SetTaxCode(Bene beneDetails)
{if…

Gkm
- 237
- 1
- 5
- 19
0
votes
0 answers
c# SpecFlow, how to get an Example row index in a scenario from ScenarioContext (or other test context)
In c# SpecFlow, in the method AfterScenario for example, I can get the Scenario Title as ScenarioContext.Current.ScenarioInfo.Title
If the Scenario contains many Examples (in the sense of Gherkin feature file) and I would like to get the Example…

Youcef Kelanemer
- 107
- 1
- 9