Skip to content

AssemblyCleanup exception hides test failure #7308

@greuelpirat

Description

@greuelpirat

An exception in AssemblyCleanup hides test exception

Steps To Reproduce

Run this:

[TestClass]
public sealed class Test1
{
    [TestMethod]
    public void TestMethod1()
    {
        Assert.Fail("I want to see this");
    }

    [AssemblyCleanup]
    public static void Shutdown()
    {
        throw new Exception("... but I only see this");
    }
}

Expected behavior

"I want to see this" should be seen in the output

Actual behavior

but this is the only output:

   ...\MSTestProject1.dll : error TESTERROR: 
      TestMethod1 (140ms): Fehlermeldung: Fehler bei der Methode "Test1.Shutdown" für die Assemblybereinigung. Fehlermeldung: System.Exception: ... but I only see this. "StackTrace":     bei MSTestPro
      ject1.Test1.Shutdown() in ...\MSTestProject1\Test1.cs:Zeile 15.
      
      Stapelverfolgung:
         bei Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestAssemblyInfo.ExecuteAssemblyCleanup() in /_/src/Adapter/MSTest.TestAdapter/Execution/TestAssemblyInfo.cs:Zeile 316.
         bei Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.UnitTestRunner.RunAssemblyCleanupIfNeeded(ITestContext testContext, ClassCleanupManager classCleanupManager, TypeCache typ

Metadata

Metadata

Labels

Area: FixturesArea: MSTestIssues with MSTest that are not specific to more refined area (e.g. analyzers or assertions)

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions