Share via


VsTestClassBase.Assert Method

Supports assertion handling in the generated test cases.

Namespace: Microsoft.SpecExplorer.Runtime.Testing
Assembly: Microsoft.SpecExplorer.Runtime.VisualStudio (in Microsoft.SpecExplorer.Runtime.VisualStudio.dll)

Usage

'Usage

Syntax

'Declaration
public override void Assert (
    bool condition,
    string description
)

Parameters

  • condition
    The condition to check.
  • description
    The message to include in the exception that is thrown when condition is false.

Remarks

When Spec Explorer produces a step based on a rule that contains a call to the Condition.AssertIsTrue method, the generated test case calls the Assert method of its test manager. The test manager then calls the Assert method of the test class. The test manager for the test is initialized in the InitializeTestManager method.

This method throws an AssertFailedException to indicate that condition is false.

If the TestMethodReturnType switch is set to none or "void", the TestPassedReturnValue, TestFailedReturnValue, and TestFailedExceptionType switches are ignored, and exceptions are not caught by the test case; that is, any exceptions generated by the test case are thrown to and handled by the test harness.

If the TestMethodReturnType, TestPassedReturnValue, and TestFailedReturnValue switches are set to something other than their default values, each test case is wrapped in a try-catch block. If, in addition, the TestFailedExceptionType switch is set to a value other than none, each test case is wrapped in a try-catch block that catches only the specified exception type. Such exceptions specifically indicate that the test case encountered a conformance error, and the test manager raises such exceptions only if the test manager's ThrowTestFailureException property is set to true.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Platforms

Development Platforms

Microsoft Windows 7, Microsoft Windows Vista, Microsoft Windows XP SP2 or later, Microsoft Windows Server 2008, Microsoft Windows Server 2003

See Also

Reference

VsTestClassBase Class
VsTestClassBase Members
Microsoft.SpecExplorer.Runtime.Testing Namespace
Assume
GeneratedTestClassBase.InitializeTestManager Method
DefaultTestManager.ThrowTestFailureException Property
DefaultTestManager.Assert Method
Condition.AssertIsTrue Method

Other Resources

Test Code Generation Switches
Test Execution Switches