Skip to content

An exception in AssemblyCleanup hides test exception #15374

@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

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions