== 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,vbnet,diff-id=1,diff-type=noncompliant] ---- ' Noncompliant Public Sub Method_NullParam() Dim sut As New MyService() sut.Method(Nothing) End Sub ---- ==== Compliant solution [source,vbnet,diff-id=1,diff-type=compliant] ---- Public Sub Method_NullParam() Dim sut As New MyService() Assert.ThrowsException(Of ArgumentNullException)(Sub() sut.Method(Nothing)) End Sub ----