IBasicTestSite Interface
Declares methods that the DefaultTestManager class calls to support basic reporting and logging functions.
Namespace: Microsoft.SpecExplorer.Runtime.Testing
Assembly: Microsoft.SpecExplorer.Runtime (in Microsoft.SpecExplorer.Runtime.dll)
Usage
'Usage
Syntax
'Declaration
public interface IBasicTestSite
Example
The following Cord script and C# example shows an implementation of a custom test class, MyTestClass, and a custom test site, MyTestSite.
In the Cord script, the Main configuration block sets some of the test generation switches, in particular, the TestClassBase switch, which indicates which base test class Spec Explorer should use in the generated test code.
In the C# code, the InitializeTestManager method of the test class initializes the test manager that will supervise the execution of the test case. Here the test manager is initialized to use a custom test site, MyTestSite.
config Main
{
switch GeneratedTestPath = "..\\TestSuite";
switch GeneratedTestNamespace = "TypeBindingSample";
switch TestClassBase = "TypeBindingSample.MyTestClass";
// Set other switches here.
}
using System;
using Microsoft.SpecExplorer.Runtime.Testing;
namespace TypeBindingSample
{
// The custom test class.
public class MyTestClass : VsTestClassBase
{
// Initialize the test manager to use a custom test site.
public override void InitializeTestManager()
{
this.Manager = new DefaultTestManager(new MyTestSite(), 32, 16);
}
}
// The custom test site.
public class MyTestSite : IBasicTestSite
{
public void Assert(bool condition, string description)
{
if (!condition)
{
Console.WriteLine("Assert failed: " + description);
throw new Exception(description);
}
}
// Implement the remaining IBasicTestSite methods here.
}
}
Remarks
During test code generation and on-the-fly testing, Spec Explorer extends the test class specified by the TestClassBase switch. The VsTestClassBase class provides a base test class that is suitable for the Visual Studio testing tools environment. In general, to create a base test class for a testing environment outside Visual Studio, define a custom base test class that extends the GeneratedTestClassBase class.
The site parameter of the DefaultTestManager constructor indicates which object supplies reporting and logging methods to the test manager. The GeneratedTestClassBase and VsTestClassBase classes initialize the test manager in a test initialization method, the InitializeTestManager method. Both the GeneratedTestClassBase and VsTestClassBase classes implement the IBasicTestSite interface. The implementation of the InitializeTestManager method provides the test class object as the site parameter to the DefaultTestManager constructor.
To create a base test class for a test environment that requires the test class to extend a specific base class, write the custom base test class such that it extends the required base class and implements the IGeneratedTestClass and IConfigurableGeneratedTestClass interfaces. Optionally, the custom base test class can implement the IBasicTestSite interface.
Platforms
Development Platforms
Microsoft Windows 7, Microsoft Windows Vista, Microsoft Windows XP SP2 or later, Microsoft Windows Server 2008, Microsoft Windows Server 2003
Change History
See Also
Reference
IBasicTestSite Members
Microsoft.SpecExplorer.Runtime.Testing Namespace
DefaultTestManager Class
GeneratedTestClassBase Class
VsTestClassBase
IGeneratedTestClass
IConfigurableGeneratedTestClass