ExpectedExceptionAttribute.Message Property
Message to include in the test result if the test fails due to not throwing an exception.
Namespace: Microsoft.VisualStudio.TestTools.UnitTesting
Assembly: Microsoft.VisualStudio.QualityTools.UnitTestFramework (in Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll)
'Declaration
Public ReadOnly Property Message As String
'Usage
Dim instance As ExpectedExceptionAttribute
Dim value As String
value = instance.Message
public string Message { get; }
public:
property String^ Message {
String^ get ();
}
public function get Message () : String
Type: System.String
A message associated with an expected exception type.
If the test fails because the test method does not throw this expected exception, or throws none at all, this is the message that is displayed in the Error Message column of the Test Results window.
You can specify this message when you add the ExpectedExceptionAttribute attribute to your test method, as shown in the following example.
[TestMethod]
[ExpectedException (typeof(MyException), "The test failed because it expected MyException.")]
public void UnitTest1() {}
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
ExpectedExceptionAttribute Class