1
// ***********************************************************************
2
// Copyright (c) 2007 Charlie Poole
4
// Permission is hereby granted, free of charge, to any person obtaining
5
// a copy of this software and associated documentation files (the
6
// "Software"), to deal in the Software without restriction, including
7
// without limitation the rights to use, copy, modify, merge, publish,
8
// distribute, sublicense, and/or sell copies of the Software, and to
9
// permit persons to whom the Software is furnished to do so, subject to
10
// the following conditions:
12
// The above copyright notice and this permission notice shall be
13
// included in all copies or substantial portions of the Software.
15
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
// ***********************************************************************
25
using System.Collections;
31
/// The TestRunner Interface allows client code, such as the NUnit console and
32
/// gui runners, to load and run tests. This is the lowest level interface generally
33
/// supported for running tests and is implemented by the RemoteTestRunner class in
34
/// the NUnit core as well as by other classes running on the client side.
36
/// The Load method is used to load a suite of tests from one or more
37
/// assemblies, returning a tree of TestNodes to the caller.
39
/// The CountTestCases family of methods returns the number of test cases in the
40
/// loaded suite, either in its entirety or by using a filter to count a subset of tests.
42
/// The Run family of methods performs a test run synchronously, returning a TestResult
43
/// or TestResult[] to the caller. If provided, an EventListener interface will be
44
/// notified of significant events in the running of the tests. A filter may be used
45
/// to run a subset of the tests.
47
/// BeginRun and EndRun provide a simplified form of the asynchronous invocation
48
/// pattern used in many places within the .NET framework. Because the current
49
/// implementation allows only one run to be in process at a time, an IAsyncResult
50
/// is not used at this time.
52
/// Methods to cancel a run and to wait for a run to complete are also provided. The
53
/// result of the last run may be obtained by querying the TestResult property.
56
public interface TestRunner
60
/// TestRunners are identified by an ID. So long as there
61
/// is only one test runner or a single chain of test runners,
62
/// the default id of 0 may be used. However, any client that
63
/// creates multiple runners must ensure that each one has a
64
/// unique ID in order to locate and run specific tests.
72
/// IsTestRunning indicates whether a test is in progress. To retrieve the
73
/// results from an asynchronous test run, wait till IsTestRunning is false.
81
/// Returns information about loaded assemblies
83
TestAssemblyInfo[] AssemblyInfo
89
/// The loaded test, converted to a tree of TestNodes so they can be
90
/// serialized and marshalled to a remote client.
98
/// Result of the last test run.
100
TestResult TestResult
106
#region Load and Unload Methods
108
/// Load the assemblies in a test package
110
/// <param name="package">The test package to be loaded</param>
111
/// <returns>True if the tests were loaded successfully, otherwise false</returns>
112
bool Load( TestPackage package );
115
/// Unload all tests previously loaded
120
#region CountTestCases Methods
122
/// Count Test Cases using a filter
124
/// <param name="filter">The filter to apply</param>
125
/// <returns>The number of test cases found</returns>
126
int CountTestCases(TestFilter filter );
131
/// Run all loaded tests and return a test result. The test is run synchronously,
132
/// and the listener interface is notified as it progresses.
134
/// <param name="listener">Interface to receive EventListener notifications.</param>
135
TestResult Run(ITestListener listener);
138
/// Run selected tests and return a test result. The test is run synchronously,
139
/// and the listener interface is notified as it progresses.
141
/// <param name="listener">Interface to receive EventListener notifications.</param>
142
/// <param name="filter">The filter to apply when running the tests</param>
143
TestResult Run(ITestListener listener, TestFilter filter);
146
/// Start a run of all loaded tests. The tests are run aynchronously and the
147
/// listener interface is notified as it progresses.
149
/// <param name="listener">Interface to receive EventListener notifications.</param>
150
void BeginRun(ITestListener listener);
153
/// Start a run of selected tests. The tests are run aynchronously and the
154
/// listener interface is notified as it progresses.
156
/// <param name="listener">Interface to receive EventListener notifications.</param>
157
/// <param name="filter">The filter to apply when running the tests</param>
158
void BeginRun(ITestListener listener, TestFilter filter);
161
/// Wait for an asynchronous run to complete and return the result.
163
/// <returns>A TestResult for the entire run</returns>
167
/// Cancel the test run that is in progress. For a synchronous run,
168
/// a client wanting to call this must create a separate run thread.
173
/// Wait for the test run in progress to complete. For a synchronous run,
174
/// a client wanting to call this must create a separate run thread. In
175
/// particular, a gui client calling this method is likely to hang, since
176
/// events will not be able to invoke methods on the gui thread.