Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ExpectedExceptionAttribute Constructor (Type^, String^)

 

Initializes a new instance of the ExpectedExceptionAttribute class with and expected exception type and a message that describes the exception.

Namespace:   Microsoft.VisualStudio.TestTools.UnitTesting
Assembly:  Microsoft.VisualStudio.QualityTools.UnitTestFramework (in Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll)

public:
ExpectedExceptionAttribute(
	Type^ exceptionType,
	String^ noExceptionMessage
)

Parameters

exceptionType
Type: System::Type^

An expected type of exception to be thrown by a method.

message

A message to be attached to the exception.

If exceptionType or message is null, a diagnostic message will be sent to a trace listener.

Legacy Code Example

The following class contains the method to test:

No code example is currently available or this language may not be supported.

The following test method tests the Divide method of the DivisionClass object. It tests for the existence of a DivideByZeroException.

No code example is currently available or this language may not be supported.
Return to top
Show: