Skip to content

Commit

Permalink
Make AssemblyCleanup/ClassCleanup execute even if Initialize fails. (#…
Browse files Browse the repository at this point in the history
…696)

Co-authored-by: Andrew Pham <anpha@microsoft.com>
  • Loading branch information
andrewphamvk and Andrew Pham authored Jun 5, 2020
1 parent ccc0dd8 commit 7b45d8a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 16 deletions.
6 changes: 0 additions & 6 deletions src/Adapter/MSTest.CoreAdapter/Execution/TestAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,6 @@ public bool HasExecutableCleanupMethod
return false;
}

// If assembly initialization was successful, then only call assembly cleanup.
if (this.AssemblyInitializationException != null)
{
return false;
}

return true;
}
}
Expand Down
6 changes: 0 additions & 6 deletions src/Adapter/MSTest.CoreAdapter/Execution/TestClassInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,6 @@ public bool HasExecutableCleanupMethod
return false;
}

// If class initialization was successful, then only call class cleanup.
if (this.ClassInitializationException != null)
{
return false;
}

return true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,12 @@ public void TestAssemblyHasExecutableCleanupMethodShouldReturnFalseIfAssemblyHas
}

[TestMethod]
public void TestAssemblyHasExecutableCleanupMethodShouldReturnFalseIfAssemblyInitializationThrewAnException()
public void TestAssemblyHasExecutableCleanupMethodShouldReturnTrueEvenIfAssemblyInitializationThrewAnException()
{
this.testAssemblyInfo.AssemblyCleanupMethod = this.dummyMethodInfo;
this.testAssemblyInfo.AssemblyInitializationException = new NotImplementedException();

Assert.IsFalse(this.testAssemblyInfo.HasExecutableCleanupMethod);
Assert.IsTrue(this.testAssemblyInfo.HasExecutableCleanupMethod);
}

[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,12 @@ public void TestClassInfoHasExecutableCleanupMethodShouldReturnFalseIfClassDoesN
}

[TestMethod]
public void TestClassInfoHasExecutableCleanupMethodShouldReturnFalseIfClassInitializeThrowsAnException()
public void TestClassInfoHasExecutableCleanupMethodShouldReturnTrueEvenIfClassInitializeThrowsAnException()
{
this.testClassInfo.ClassCleanupMethod = this.testClassType.GetMethods().First();
this.testClassInfo.ClassInitializationException = new NotImplementedException();

Assert.IsFalse(this.testClassInfo.HasExecutableCleanupMethod);
Assert.IsTrue(this.testClassInfo.HasExecutableCleanupMethod);
}

[TestMethod]
Expand Down

0 comments on commit 7b45d8a

Please # to comment.