Skip to content

Instantly share code, notes, and snippets.

@staxmanade
Created July 1, 2011 21:26
Show Gist options
  • Save staxmanade/1059430 to your computer and use it in GitHub Desktop.
Save staxmanade/1059430 to your computer and use it in GitHub Desktop.
Pseudo code I think could be used to leverage StatLight.Core
using System;
using System.Collections.ObjectModel;
using StatLight.Client.Harness.Events;
using StatLight.Core.Common;
using StatLight.Core.Configuration;
using StatLight.Core.Events;
using StatLight.Core.Events.Aggregation;
using StatLight.Core.Reporting;
using StatLight.Core.Runners;
using StatLight.Core.WebBrowser;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
ILogger logger = new ConsoleLogger(LogChatterLevels.Full);
var eventAggregator = new EventAggregator(logger);
// Create our custom listener and add it to the event aggregator
var reSharperTestingReportEventsHandler = new ReSharperTestingReportEventsHandler();
eventAggregator.AddListener(reSharperTestingReportEventsHandler);
var statLightConfigurationFactory = new StatLightConfigurationFactory(logger);
StatLightConfiguration config;
config = statLightConfigurationFactory.GetStatLightConfigurationForXap(
unitTestProviderType: UnitTestProviderType.Undefined, // Let StatLight figure it out
xapPath: "PathTo.Xap",
microsoftTestingFrameworkVersion: null, // Let StatLight figure it out
methodsToTest: new Collection<string> {"Namespace.subNamespace.TestclassName.MethodToTest"},
tagFilters: null,
numberOfBrowserHosts: 1, // Maybe you spin up 3 or 4 here if you know you're running a ton of tests
isRemoteRun: false,
queryString: "", // This is passed to the browser host page (say your test need some configuration - could be passed here - probably not a use case in ReSharper runner)
webBrowserType: WebBrowserType.SelfHosted,
forceBrowserStart: false,
showTestingBrowserHost: false, // If you need UI support this needs to be true
isPhoneRun: false
);
// Similar to above, except if you give it a dll to run tests in StatLight will attempt to find necessary references
// This is very experimental and not very optimized.
//config = statLightConfigurationFactory.GetStatLightConfigurationForDll(
// unitTestProviderType: UnitTestProviderType.Undefined, // Let StatLight figure it out
// dllPath: "PathTo.Dll",
// microsoftTestingFrameworkVersion: null, // Let StatLight figure it out
// methodsToTest: new Collection<string> {"Namespace.subNamespace.TestclassName.MethodToTest"},
// tagFilters: null,
// numberOfBrowserHosts: 1,
// isRemoteRun: false,
// queryString: "",
// webBrowserType: WebBrowserType.SelfHosted,
// forceBrowserStart: false,
// showTestingBrowserHost: false, // If you need UI support this needs to be true
// isPhoneRun: false
// );
var statLightRunnerFactory = new StatLightRunnerFactory(logger, eventAggregator, eventAggregator);
IRunner onetimeConsoleRunner = statLightRunnerFactory.CreateOnetimeConsoleRunner(config);
// This will be the blocking/slow operation that runs the tests...
TestReport testReport = onetimeConsoleRunner.Run();
}
}
public class ReSharperTestingReportEventsHandler : ITestingReportEvents
{
public void Handle(TestCaseResult message)
{
throw new NotImplementedException("TODO");
}
public void Handle(TraceClientEvent message)
{
throw new NotImplementedException("TODO");
}
public void Handle(BrowserHostCommunicationTimeoutServerEvent message)
{
throw new NotImplementedException("TODO");
}
public void Handle(FatalSilverlightExceptionServerEvent message)
{
throw new NotImplementedException("TODO");
}
public void Handle(UnhandledExceptionClientEvent message)
{
throw new NotImplementedException("TODO");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment