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)

Syntax

'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

Property Value

Type: System.String
A message associated with an expected exception type.

Remarks

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.

Examples

[TestMethod]
[ExpectedException (typeof(MyException), "The test failed because it expected MyException.")]
public void UnitTest1() {}

.NET Framework Security

See Also

Reference

ExpectedExceptionAttribute Class

ExpectedExceptionAttribute Members

Microsoft.VisualStudio.TestTools.UnitTesting Namespace