Class FrameworkController
FrameworkController provides a facade for use in loading, browsing and running tests without requiring a reference to the NUnit framework. All calls are encapsulated in constructors for this class and its nested classes, which only require the types of the Common Type System as arguments.
The controller supports four actions: Load, Explore, Count and Run. They are intended to be called by a driver, which should allow for proper sequencing of calls. Load must be called before any of the other actions. The driver may support other actions, such as reload on run, by combining these calls.
Inherited Members
Namespace: NUnit.Framework.Api
Assembly: nunit.framework.dll
Syntax
public class FrameworkController : LongLivedMarshalByRefObject
Constructors
View SourceFrameworkController(Assembly, string, IDictionary)
Construct a FrameworkController using the default builder and runner.
Declaration
public FrameworkController(Assembly assembly, string idPrefix, IDictionary settings)
Parameters
| Type | Name | Description |
|---|---|---|
| Assembly | assembly | The test assembly |
| string | idPrefix | A prefix used for all test ids created under this controller. |
| IDictionary | settings | A Dictionary of settings to use in loading and running the tests |
FrameworkController(Assembly, string, IDictionary, string, string)
Construct a FrameworkController, specifying the types to be used for the runner and builder. This constructor is provided for purposes of development.
Declaration
public FrameworkController(Assembly assembly, string idPrefix, IDictionary settings, string runnerType, string builderType)
Parameters
| Type | Name | Description |
|---|---|---|
| Assembly | assembly | The test assembly |
| string | idPrefix | A prefix used for all test ids created under this controller. |
| IDictionary | settings | A Dictionary of settings to use in loading and running the tests |
| string | runnerType | The Type of the test runner |
| string | builderType | The Type of the test builder |
FrameworkController(string, string?, IDictionary)
Construct a FrameworkController using the default builder and runner.
Declaration
public FrameworkController(string assemblyNameOrPath, string? idPrefix, IDictionary settings)
Parameters
| Type | Name | Description |
|---|---|---|
| string | assemblyNameOrPath | The AssemblyName or path to the test assembly |
| string | idPrefix | A prefix used for all test ids created under this controller. |
| IDictionary | settings | A Dictionary of settings to use in loading and running the tests |
FrameworkController(string, string?, IDictionary, string, string)
Construct a FrameworkController, specifying the types to be used for the runner and builder. This constructor is provided for purposes of development.
Declaration
public FrameworkController(string assemblyNameOrPath, string? idPrefix, IDictionary settings, string runnerType, string builderType)
Parameters
| Type | Name | Description |
|---|---|---|
| string | assemblyNameOrPath | The full AssemblyName or the path to the test assembly |
| string | idPrefix | A prefix used for all test ids created under this controller. |
| IDictionary | settings | A Dictionary of settings to use in loading and running the tests |
| string | runnerType | The Type of the test runner |
| string | builderType | The Type of the test builder |
Properties
View SourceAssemblyNameOrPath
Gets the AssemblyName or the path for which this FrameworkController was created
Declaration
public string AssemblyNameOrPath { get; }
Property Value
| Type | Description |
|---|---|
| string |
Builder
Gets the ITestAssemblyBuilder used by this controller instance.
Declaration
public ITestAssemblyBuilder Builder { get; }
Property Value
| Type | Description |
|---|---|
| ITestAssemblyBuilder | The builder. |
Runner
Gets the ITestAssemblyRunner used by this controller instance.
Declaration
public ITestAssemblyRunner Runner { get; }
Property Value
| Type | Description |
|---|---|
| ITestAssemblyRunner | The runner. |
Methods
View SourceCountTests(string?)
Counts the number of test cases in the loaded TestSuite
Declaration
public int CountTests(string? filter)
Parameters
| Type | Name | Description |
|---|---|---|
| string | filter | A string containing the XML representation of the filter to use |
Returns
| Type | Description |
|---|---|
| int | The number of tests |
ExploreTests(string?)
Returns info about the tests in an assembly
Declaration
public string ExploreTests(string? filter)
Parameters
| Type | Name | Description |
|---|---|---|
| string | filter | A string containing the XML representation of the filter to use |
Returns
| Type | Description |
|---|---|
| string | The XML result of exploring the tests |
InsertEnvironmentElement(TNode)
Inserts environment element
Declaration
public static TNode InsertEnvironmentElement(TNode targetNode)
Parameters
| Type | Name | Description |
|---|---|---|
| TNode | targetNode | Target node |
Returns
| Type | Description |
|---|---|
| TNode | The new node |
InsertSettingsElement(TNode, IDictionary<string, object>)
Inserts settings element
Declaration
public static TNode InsertSettingsElement(TNode targetNode, IDictionary<string, object> settings)
Parameters
| Type | Name | Description |
|---|---|---|
| TNode | targetNode | Target node |
| IDictionary<string, object> | settings | Settings dictionary |
Returns
| Type | Description |
|---|---|
| TNode | The new node |
LoadTests()
Loads the tests in the assembly
Declaration
public string LoadTests()
Returns
| Type | Description |
|---|---|
| string |
RunTests(Action<string>, string)
Runs the tests in an assembly synchronously reporting back the test results through the callback or through the return value
Declaration
public string RunTests(Action<string> callback, string filter)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<string> | callback | The callback that receives the test results |
| string | filter | A string containing the XML representation of the filter to use |
Returns
| Type | Description |
|---|---|
| string | The XML result of the test run |
RunTests(string?)
Runs the tests in an assembly
Declaration
public string RunTests(string? filter)
Parameters
| Type | Name | Description |
|---|---|---|
| string | filter | A string containing the XML representation of the filter to use |
Returns
| Type | Description |
|---|---|
| string | The XML result of the test run |
StopRun(bool)
Stops the test run
Declaration
public void StopRun(bool force)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | force | True to force the stop, false for a cooperative stop |