我目前正在使用mbunit构建测试套件.到目前为止一切顺利,但我没有使用包含的Icarus GUI,而是希望拥有自己的测试运行器.我不太了解该怎么做,我继续使用Gallio的Google小组并复制用户发布的代码:
http://groups.google.com/group/gallio-user/browse_thread/thread/afab404a14674cd2
我得到了以下异常:
Gallio.Runtime.RuntimeException未处理Message =无法解析服务类型'Gallio.Runner.Projects.ITestProjectManager'的组件,因为似乎没有为该服务类型注册和启用任何组件.源=加利奥堆栈跟踪:在Gallio.Runtime.Extensibility.RegistryServiceLocator.ResolveNonDisabledDescriptor(类型的serviceType)在Gallio.Runtime.Extensibility.RegistryServiceLocator.ResolveImpl(类型的serviceType)在Gallio.Runtime.Extensibility.RegistryServiceLocator.ResolveTService在Gallio.Runner.TestLauncher.在Gallio.Runner.TestLauncher.Run()中的Dallas.Dashboard.TestSystem.TestPrograms.Driver.RunTests()在C:\ Users\edmondc\Documents\Visual Studio 2010\Projects\AutomatedTestSystem\TestPrograms\ImageComparisonTest\Driver中运行RunWithRuntime() .cs:Dundas.Dashboard.TestSystem.Program.Main(String [] args)中的第49行,位于C:\ Users\edmondc\Documents\Visual Studio 2010\Projects\AutomatedTestSystem\TestConsole\Program.cs:第13行中的System. System.Threading.ThreadH上的Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()中的System.AppDomain.ExecuteAssembly(String assemblyFile,Evidence assemblySecurity,String [] args)中的AppDomain._nExecuteAssembly(RuntimeAssembly程序集,String [] args)System.Threading上System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback回调,对象状态)的System.Threading.ExecutionContext.Run(ExecutionContext executionContext,ContextCallback回调,Object状态,Boolean ignoreSyncCtx)中的elper.ThreadStart_Context(Object state) .ThreadHelper.ThreadStart()InnerException:
我在那里做错了什么?
您可能希望使用可能位于Gallio安装目录中某处的Gallio Loader.加载器是作为一些C#源文件提供的,您需要在项目中包含这些文件.其目的是简化Gallio在自定义应用程序中的集成.
一个简单的用法如下:
TestLauncher launcher = new TestLauncher();
launcher.AddFilePattern("MyTestAssembly.dll");
TestLauncherResult result = launcher.Run();
Run Code Online (Sandbox Code Playgroud)
编辑:有关测试启动器的更复杂用法,请查看Echo源代码.