== How to fix it in MSTest Remove the `ExpectedException` attribute in favor of using the https://learn.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.testtools.unittesting.assert.throwsexception[Assert.ThrowsException] assertion. === Code examples ==== Noncompliant code example [source,csharp,diff-id=1,diff-type=noncompliant] ---- [TestMethod] [ExpectedException(typeof(ArgumentNullException))] // Noncompliant public void Method_NullParam() { var sut = new MyService(); sut.Method(null); } ---- ==== Compliant solution [source,csharp,diff-id=1,diff-type=compliant] ---- [TestMethod] public void Method_NullParam() { var sut = new MyService(); Assert.ThrowsException(() => sut.Method(null)); } ----