Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invoking mbunit Test Runner Programmatically

Tags:

c#

mbunit

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?

like image 811
edc Avatar asked Aug 17 '11 20:08

edc


1 Answers

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.

like image 79
Yann Trevin Avatar answered Sep 24 '22 14:09

Yann Trevin