Skip to content

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

@AbhitejJohn

Description

@AbhitejJohn

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions