Invoking mbunit Test Runner Programmatically
Asked Answered
S

1

6

I am currently building a test suite using mbunit. So far so good, but instead of using the included Icarus GUI, I want to have my own test runner. Not knowing much about what to do, I go on Gallio's Google group and copied the code posted by a user:

http://groups.google.com/group/gallio-user/browse_thread/thread/afab404a14674cd2

And I got the following exception instead:

Gallio.Runtime.RuntimeException was unhandled Message=Could not resolve component for service type 'Gallio.Runner.Projects.ITestProjectManager' because there do not appear to be any components registered and enabled for that service type. Source=Gallio StackTrace: at Gallio.Runtime.Extensibility.RegistryServiceLocator.ResolveNonDisabledDescriptor(Type serviceType) at Gallio.Runtime.Extensibility.RegistryServiceLocator.ResolveImpl(Type serviceType) at Gallio.Runtime.Extensibility.RegistryServiceLocator.ResolveTService at Gallio.Runner.TestLauncher.RunWithRuntime() at Gallio.Runner.TestLauncher.Run() at Dundas.Dashboard.TestSystem.TestPrograms.Driver.RunTests() in C:\Users\edmondc\Documents\Visual Studio 2010\Projects\AutomatedTestSystem\TestPrograms\ImageComparisonTest\Driver.cs:line 49 at Dundas.Dashboard.TestSystem.Program.Main(String[] args) in C:\Users\edmondc\Documents\Visual Studio 2010\Projects\AutomatedTestSystem\TestConsole\Program.cs:line 13 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:

What am I doing wrong there?

Somali answered 17/8, 2011 at 20:33 Comment(0)
G
7

You may want to use the Gallio Loader which might be found somewhere in the installation directory of Gallio. The loader is provided as a couple of C# source files that you need to include in your project. Its purpose is to ease the integration of Gallio in custom applications.

A simple usage is the following:

TestLauncher launcher = new TestLauncher();
launcher.AddFilePattern("MyTestAssembly.dll");
TestLauncherResult result = launcher.Run();

EDIT: For a more complex usage of the test launcher, have a look at the Echo source code.

Greenlaw answered 19/8, 2011 at 9:35 Comment(1)
This is exactly what I am looking for - a simple test runner class that allows me to load assemblies on the fly. Thanks!Somali

© 2022 - 2024 — McMap. All rights reserved.