Questions tagged [testcontext]

38 questions
46
votes
5 answers

Understanding the MSTest TestContext

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…
Richard Ev
  • 52,939
  • 59
  • 191
  • 278
5
votes
0 answers

Azure Pipelines - Visual Studio Test does not publish results from TestContext.WriteLine

We are using Azure DevOps to run a build that runs tests using Visual Studio Test. Everything is working fine, Console.WriteLine lines are being written to Standard Console Output.log, however TestContext.WriteLine are not appearing in the Detailed…
elgato
  • 506
  • 1
  • 5
  • 20
5
votes
0 answers

C# unit testing - ordered test with runsettings file

I'm trying to develope an automated regression test framework as unit tests. So I use ordered test to combine the different test steps and combine them in an easy to use way. For configuration purposes i wanna use the runsettings file, especially…
5
votes
1 answer

Unit test TestContext Multiple calls

I have a Test Method which is calling 2 Sub Test Methods. Both the sub Methods are Data Driven from an XML file. If I run each sub methods they run fine and successful. However, when I run Main Test Method (caller of both sub methods) it finds…
rocky
  • 157
  • 3
  • 13
3
votes
1 answer

What is the purpose of directories defined by TestContext?

These are the (non-deprecated) directories defined in TestContext class and their respective definitions. DeploymentDirectory Gets the directory for files deployed for the test run. This property typically contains a subdirectory of…
matt-pielat
  • 1,659
  • 3
  • 20
  • 33
3
votes
0 answers

MSTest: why is TestOutcome = InProgress after ExpectedCondition?

I have the following tryout code: [TestMethod] public void VisibilitySucces() { testPage.HideParagraph(); testPage.ShowParagraph(); } [TestMethod, ExpectedException(typeof(WebDriverTimeoutException))] public void…
FDM
  • 628
  • 6
  • 18
2
votes
1 answer

What are "Context" for "Run Tests in Context" and "Debug Tests in Context" and "Run .NET Core Test in context" in Visual Studio Code?

In Visual Studio Code, I am really confused by the 3 "Context" menu items: Run Tests in Context and Debug Tests in Context and Run .NET Core Test in context, what Context are they expecting? In my understanding, TestContext will be initialized via…
Dongdong
  • 2,208
  • 19
  • 28
2
votes
2 answers

How can I get access to the current test method in NUnit

TestContext.CurrentContext.Test has several properties like FullName which can be parsed to get the current test method within NUnit. However, these don't help at all when the test's name is overridden using the TestName property on the TestCase…
ChaseMedallion
  • 20,860
  • 17
  • 88
  • 152
1
vote
1 answer

How can I get an instance of the MSTest V2 TestContext in the TestCleanup method?

I'm migrating an existing codebase to MSTest V2 and running into a problem with the TestContext in the TestCleanup method. In MSTest V1 the TestContext class was static but in V2 it is an instance. I tried to add a parameter to the TestCleanup…
Darrel
  • 376
  • 2
  • 9
1
vote
1 answer

How to pass custom data to the log4net.Core.LoggingEvent object?

I want to get custom data from the log4net.Core.LoggingEvent object inside Append method of my custom log4net appender. public sealed class SimpleAppender : AppenderSkeleton { protected override void Append(LoggingEvent loggingEvent) { …
Joseph Katzman
  • 1,959
  • 6
  • 21
  • 47
1
vote
1 answer

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

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…
Nandakumar1712
  • 357
  • 1
  • 4
  • 11
1
vote
1 answer

How to execute code before MSTest TestContext is set

For our data-driven tests we're using Excel files for datasource. Now, because the Excel files are binary data, we had a lot of headaches with git (not being able to diff, files overwritten and implicitly a lot of false positives due to incorrect…
Cosmin
  • 2,354
  • 2
  • 22
  • 39
1
vote
0 answers

C# - .NET - MSTest - Test context - Add result file - Selenium Screenshots - Issue while viewing the result file

I have a Selenium test automation suite ( in MS Stack ) where I take a screenshot for every test ( incase of failure ) and try attaching to the test result. I am using this solution to attach the screenshot to the result file. c# - selenium -…
Timothy Rajan
  • 1,947
  • 8
  • 38
  • 62
1
vote
1 answer

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

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…
Timothy Rajan
  • 1,947
  • 8
  • 38
  • 62
1
vote
0 answers

BeanCreationException while preparing instance using TestContextManager

I would like to understand the difference between the below two variants: 1: @RunWith(Parameterized.class) @DirtiesContext(classMode = DirtiesContext.ClassMode.BEFORE_CLASS) @ContextConfiguration(loader = SpringockitoContextLoader.class, locations…
Sowmiya
  • 313
  • 2
  • 12
1
2 3