C# Class Microsoft.Silverlight.Testing.Harness.UnitTestHarness

A test harness for interacting with unit test providers such as Visual Studio Team Test's metadata.
Show file Open project: garyjohnson/wpnest Class Usage Examples

Public Methods

Method Description
AddLogProvider ( Microsoft.Silverlight.Testing.Harness.LogProvider provider ) : void

Adds a log provider to the listening log providers group.

EnqueueTestAssembly ( Assembly assembly, TestRunFilter runFilter ) : void

Enqueue a test assembly from a simple Assembly reference.

EnqueueTestAssembly ( IAssembly testAssembly, TestRunFilter runFilter ) : void

Enqueues a test assembly.

Initialize ( ) : void

Initialize the harness with a set of test assemblies.

PrepareCustomTestInstance ( CustomFrameworkUnitTest customTest ) : void

Sets the unit test harness property for a test case that inherits from the abstract base type 'CustomTest'.

QueueLogMessage ( Microsoft.Silverlight.Testing.Harness.LogMessage message ) : void

Enqueue a log message object for processing by the log providers.

RestartRunDispatcher ( ) : void

Restarts the run dispatcher.

Run ( ) : void

Begin running the test harness.

Make sure to subscribe to the Complete event before calling this method, in some harnesses this may be a synchronous Run followed immediately by the Complete event being fired.

TrackScenarioResult ( ScenarioResult result ) : void

Track the results for our execution and also track the fail state.

UnitTestHarness ( ) : System

Initiate unit test harness.

WriteLogFile ( string logName, string fileContent ) : void

Stores a log file for the test run. Depending on the execution environment, this call may not successful.

Protected Methods

Method Description
CreateTestRunFilter ( UnitTestSettings settings ) : TestRunFilter

Creates the test run filter for the initial run.

OnIsDispatcherRunningChanged ( EventArgs e ) : void

Fires the play pause event.

OnPublishing ( EventArgs e ) : void

Call the Publishing event.

OnTestAssemblyCompleted ( TestAssemblyCompletedEventArgs e ) : void

Fires the test assembly completed event.

OnTestAssemblyStarting ( TestAssemblyStartingEventArgs e ) : void

Fires the test assembly starting event.

OnTestClassCompleted ( TestClassCompletedEventArgs e ) : void

Fires the test class completed event.

OnTestClassStarting ( TestClassStartingEventArgs e ) : void

Fires the test class starting event.

OnTestHarnessCompleted ( ) : void

Call the TestHarnessCompleted event.

OnTestMethodCompleted ( TestMethodCompletedEventArgs e ) : void

Notifies observers that a test method has been completed. Also clears the test panel's visual tree.

OnTestMethodStarting ( Microsoft.Silverlight.Testing.Harness.TestMethodStartingEventArgs e ) : void

Fires the test method starting event.

OnTestRunStarting ( TestRunStartingEventArgs e ) : void

Notifies observers that a test run has been started.

ProcessLogMessages ( ) : void

Process all queued log messages.

PublishFinalResult ( ) : void

If supported by any attached test service, this publishes the final test results. Typical harness implementations may immediately close the web browser channel upon receiving the message, so any other reporting should be done first.

PublishResults ( ) : void

Overrides the PublishResults method so that final reporting is only done once all other logging is finished.

RunNextStep ( ) : bool

Flush the current log manager and then perform the next invoke.

Private Methods

Method Description
CalculateTotalMethods ( AssemblyManager assemblyManager, IAssembly assembly, TestRunFilter filter ) : int

Calculates the number of methods for a run.

CreateHarnessTasks ( ) : void

Creates the set of harness tasks to run and hooks up to the Complete event.

GlobalUnhandledExceptionListener ( object sender, EventArgs e ) : void

Listener event for any unhandled exceptions.

HarnessComplete ( object sender, EventArgs e ) : void

Event fired at the completion of the harness' work.

InitializeLogProviders ( ) : void

Initializes all log providers.

InitializeSettings ( UnitTestSettings settings ) : void

Fill member variables with any non-null settings of the same type.

IsReportingTestServiceConnected ( ) : bool

Checks if a reporting provider is connected to the test service.

PrepareTestAssemblyTasks ( ) : void

Determine what test assemblies need to be executed. Enqueue tasks for the unit test assembly providers to run the tests.

PublishFinalResults ( ) : void

Publish final results. If not yet ready, will keep waiting around as a work item until it is done.

ReportCodeCoverage ( TestServiceProvider testService ) : void
RunDispatcherComplete ( object sender, EventArgs e ) : void
SetOverallStatus ( string message ) : void

Immediately sets the overall status using a log message and processes the message queue.

Method Details

AddLogProvider() public method

Adds a log provider to the listening log providers group.
public AddLogProvider ( Microsoft.Silverlight.Testing.Harness.LogProvider provider ) : void
provider Microsoft.Silverlight.Testing.Harness.LogProvider Log provider object.
return void

CreateTestRunFilter() protected method

Creates the test run filter for the initial run.
protected CreateTestRunFilter ( UnitTestSettings settings ) : TestRunFilter
settings UnitTestSettings The unit test settings.
return TestRunFilter

EnqueueTestAssembly() public method

Enqueue a test assembly from a simple Assembly reference.
public EnqueueTestAssembly ( Assembly assembly, TestRunFilter runFilter ) : void
assembly System.Reflection.Assembly The test assembly.
runFilter TestRunFilter The run filter settings for the test assembly's run.
return void

EnqueueTestAssembly() public method

Enqueues a test assembly.
public EnqueueTestAssembly ( IAssembly testAssembly, TestRunFilter runFilter ) : void
testAssembly IAssembly The test assembly metadata.
runFilter TestRunFilter The run filter settings for the test assembly's run.
return void

Initialize() public method

Initialize the harness with a set of test assemblies.
public Initialize ( ) : void
return void

OnIsDispatcherRunningChanged() protected method

Fires the play pause event.
protected OnIsDispatcherRunningChanged ( EventArgs e ) : void
e System.EventArgs Event data.
return void

OnPublishing() protected method

Call the Publishing event.
protected OnPublishing ( EventArgs e ) : void
e System.EventArgs The event arguments.
return void

OnTestAssemblyCompleted() protected method

Fires the test assembly completed event.
protected OnTestAssemblyCompleted ( TestAssemblyCompletedEventArgs e ) : void
e TestAssemblyCompletedEventArgs The event data.
return void

OnTestAssemblyStarting() protected method

Fires the test assembly starting event.
protected OnTestAssemblyStarting ( TestAssemblyStartingEventArgs e ) : void
e TestAssemblyStartingEventArgs The event data.
return void

OnTestClassCompleted() protected method

Fires the test class completed event.
protected OnTestClassCompleted ( TestClassCompletedEventArgs e ) : void
e TestClassCompletedEventArgs The event data.
return void

OnTestClassStarting() protected method

Fires the test class starting event.
protected OnTestClassStarting ( TestClassStartingEventArgs e ) : void
e TestClassStartingEventArgs The event data.
return void

OnTestHarnessCompleted() protected method

Call the TestHarnessCompleted event.
protected OnTestHarnessCompleted ( ) : void
return void

OnTestMethodCompleted() protected method

Notifies observers that a test method has been completed. Also clears the test panel's visual tree.
protected OnTestMethodCompleted ( TestMethodCompletedEventArgs e ) : void
e TestMethodCompletedEventArgs The event data.
return void

OnTestMethodStarting() protected method

Fires the test method starting event.
protected OnTestMethodStarting ( Microsoft.Silverlight.Testing.Harness.TestMethodStartingEventArgs e ) : void
e Microsoft.Silverlight.Testing.Harness.TestMethodStartingEventArgs The event data.
return void

OnTestRunStarting() protected method

Notifies observers that a test run has been started.
protected OnTestRunStarting ( TestRunStartingEventArgs e ) : void
e TestRunStartingEventArgs The event data.
return void

PrepareCustomTestInstance() public method

Sets the unit test harness property for a test case that inherits from the abstract base type 'CustomTest'.
public PrepareCustomTestInstance ( CustomFrameworkUnitTest customTest ) : void
customTest CustomFrameworkUnitTest A CustomText instance.
return void

ProcessLogMessages() protected method

Process all queued log messages.
protected ProcessLogMessages ( ) : void
return void

PublishFinalResult() protected method

If supported by any attached test service, this publishes the final test results. Typical harness implementations may immediately close the web browser channel upon receiving the message, so any other reporting should be done first.
protected PublishFinalResult ( ) : void
return void

PublishResults() protected method

Overrides the PublishResults method so that final reporting is only done once all other logging is finished.
protected PublishResults ( ) : void
return void

QueueLogMessage() public method

Enqueue a log message object for processing by the log providers.
public QueueLogMessage ( Microsoft.Silverlight.Testing.Harness.LogMessage message ) : void
message Microsoft.Silverlight.Testing.Harness.LogMessage The log message object.
return void

RestartRunDispatcher() public method

Restarts the run dispatcher.
public RestartRunDispatcher ( ) : void
return void

Run() public method

Begin running the test harness.
Make sure to subscribe to the Complete event before calling this method, in some harnesses this may be a synchronous Run followed immediately by the Complete event being fired.
public Run ( ) : void
return void

RunNextStep() protected method

Flush the current log manager and then perform the next invoke.
protected RunNextStep ( ) : bool
return bool

TrackScenarioResult() public method

Track the results for our execution and also track the fail state.
public TrackScenarioResult ( ScenarioResult result ) : void
result ScenarioResult Scenario result to process.
return void

UnitTestHarness() public method

Initiate unit test harness.
public UnitTestHarness ( ) : System
return System

WriteLogFile() public method

Stores a log file for the test run. Depending on the execution environment, this call may not successful.
public WriteLogFile ( string logName, string fileContent ) : void
logName string The name of the log file.
fileContent string The log file content as a string.
return void