// **************************************************************** // This is free software licensed under the NUnit license. You // may obtain a copy of the license as well as information regarding // copyright ownership at http://nunit.org/?p=license&r=2.4. // **************************************************************** using System; using System.Collections; using System.IO; namespace NUnit.Core { /// /// The TestRunner Interface allows client code, such as the NUnit console and /// gui runners, to load and run tests. This is the lowest level interface generally /// supported for running tests and is implemented by the RemoteTestRunner class in /// the NUnit core as well as by other classes running on the client side. /// /// The Load method is used to load a suite of tests from one or more /// assemblies, returning a tree of TestNodes to the caller. /// /// The CountTestCases family of methods returns the number of test cases in the /// loaded suite, either in its entirety or by using a filter to count a subset of tests. /// /// The Run family of methods performs a test run synchronously, returning a TestResult /// or TestResult[] to the caller. If provided, an EventListener interface will be /// notified of significant events in the running of the tests. A filter may be used /// to run a subset of the tests. /// /// BeginRun and EndRun provide a simplified form of the asynchronous invocation /// pattern used in many places within the .NET framework. Because the current /// implementation allows only one run to be in process at a time, an IAsyncResult /// is not used at this time. /// /// Methods to cancel a run and to wait for a run to complete are also provided. The /// result of the last run may be obtained by querying the TestResult property. /// /// public interface TestRunner { #region Properties /// /// TestRunners are identified by an ID. So long as there /// is only one test runner or a single chain of test runners, /// the default id of 0 may be used. However, any client that /// creates multiple runners must ensure that each one has a /// unique ID in order to locate and run specific tests. /// int ID { get; } /// /// IsTestRunning indicates whether a test is in progress. To retrieve the /// results from an asynchronous test run, wait till IsTestRunning is false. /// bool Running { get; } /// /// Returns information about loaded assemblies /// IList AssemblyInfo { get; } /// /// The loaded test, converted to a tree of TestNodes so they can be /// serialized and marshalled to a remote client. /// ITest Test { get; } /// /// Result of the last test run. /// TestResult TestResult { get; } #endregion #region Load and Unload Methods /// /// Load the assemblies in a test package /// /// The test package to be loaded /// True if the tests were loaded successfully, otherwise false bool Load( TestPackage package ); /// /// Unload all tests previously loaded /// void Unload(); #endregion #region CountTestCases Methods /// /// Count Test Cases using a filter /// /// The filter to apply /// The number of test cases found int CountTestCases(ITestFilter filter ); #endregion #region Run Methods /// /// Run all loaded tests and return a test result. The test is run synchronously, /// and the listener interface is notified as it progresses. /// /// Interface to receive EventListener notifications. TestResult Run(NUnit.Core.EventListener listener); /// /// Run selected tests and return a test result. The test is run synchronously, /// and the listener interface is notified as it progresses. /// /// Interface to receive EventListener notifications. /// The filter to apply when running the tests TestResult Run(NUnit.Core.EventListener listener, ITestFilter filter); /// /// Start a run of all loaded tests. The tests are run aynchronously and the /// listener interface is notified as it progresses. /// /// Interface to receive EventListener notifications. void BeginRun(NUnit.Core.EventListener listener); /// /// Start a run of selected tests. The tests are run aynchronously and the /// listener interface is notified as it progresses. /// /// Interface to receive EventListener notifications. /// The filter to apply when running the tests void BeginRun(NUnit.Core.EventListener listener, ITestFilter filter); /// /// Wait for an asynchronous run to complete and return the result. /// /// A TestResult for the entire run TestResult EndRun(); /// /// Cancel the test run that is in progress. For a synchronous run, /// a client wanting to call this must create a separate run thread. /// void CancelRun(); /// /// Wait for the test run in progress to complete. For a synchronous run, /// a client wanting to call this must create a separate run thread. In /// particular, a gui client calling this method is likely to hang, since /// events will not be able to invoke methods on the gui thread. /// void Wait(); #endregion } }