Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestContext.CurrentTestOutcome is always InProgress in the TestCleanup method #89

Closed
AbhitejJohn opened this issue Feb 27, 2017 · 2 comments
Milestone

Comments

@AbhitejJohn
Copy link
Contributor

Copied from #Microsft/vstest/548.

Description

In the TestCleanup method, the TestContext.CurrentTestOutcome property is always InProgress rather than the actual current test outcome.

Using the old test framework (bundled with VS, New > Project > Unit Test) the outcome is set correctly.

Steps to reproduce

using Microsoft.VisualStudio.TestTools.UnitTesting;

[TestClass]
public class MyTestClass
{
	public TestContext TestContext { get; set; }

	[TestMethod]
	public void PassTest()
	{
		Assert.IsTrue(true);
	}

	[TestMethod]
	public void InconclusiveTest()
	{
		Assert.Inconclusive();
	}

	[TestMethod]
	public void FailTest()
	{
		Assert.Fail();
	}

	[TestCleanup]
	public void TestCleanup()
	{
		System.Console.WriteLine($"{TestContext.TestName}: {TestContext.CurrentTestOutcome}");
	}
}

Expected behavior

TestContext.CurrentTestOutcome is set to the actual outcome type of the current test.

image

Image taken when executing the code above using the old VS-bundled framework.

Actual behavior

TestContext.CurrentTestOutcome is always InProgress

image

Image taken when executing the code above using the new NuGet package framework.

Environment

  Version
OS Windows 10 Enterprise build 14393
IDE Visual Studio Enterprise 2015 Update 3
Target framework 4.5.2
MSTest.TestAdapter 1.1.12
MSTest.TestFramework 1.1.11
@savehansson
Copy link

I get the same in VS 2017. And possibly related:

A TestContext.WriteLine("Some trace message"); in the test method doesn't produce any output. There's no Output link in the Test Explorer's right pane.

If I call any other output method, like Console.WriteLine(), there's a Output link, but the output doesn't contain the trace messages written with TestContext.WriteLine().

@AbhitejJohn
Copy link
Contributor Author

@hawkunsh: #120 is tracking the TestContext.WriteLine issue.

@AbhitejJohn AbhitejJohn added this to the S116 milestone Apr 3, 2017
singhsarab pushed a commit to singhsarab/testfx that referenced this issue Apr 8, 2019
Fix the stackoverflow by removing multi-registration of converters
singhsarab pushed a commit to singhsarab/testfx that referenced this issue Apr 8, 2019
StackOverflowFix Port: Merge pull request microsoft#89 from saikrishnav/stackoverflowfix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants