当前位置: 首页>>代码示例>>C#>>正文


C# TestRunner.RunAssembly方法代码示例

本文整理汇总了C#中TestRunner.RunAssembly方法的典型用法代码示例。如果您正苦于以下问题:C# TestRunner.RunAssembly方法的具体用法?C# TestRunner.RunAssembly怎么用?C# TestRunner.RunAssembly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TestRunner的用法示例。


在下文中一共展示了TestRunner.RunAssembly方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Execute

        public override bool Execute()
        {
            RemotingUtility.CleanUpRegisteredChannels();

            try
            {
                ExitCode = 0;

                string projectFilename = ProjectFile.GetMetadata("FullPath");
                XunitProject project = XunitProject.Load(projectFilename);
                IRunnerLogger logger =
                    TeamCity ? (IRunnerLogger)new TeamCityLogger(Log, () => cancel) :
                    Verbose ? new VerboseLogger(Log, () => cancel) :
                    new StandardLogger(Log, () => cancel);

                Log.LogMessage(MessageImportance.High, "xUnit.net MSBuild runner ({0}-bit .NET {1})", IntPtr.Size * 8, Environment.Version);

                foreach (XunitProjectAssembly assembly in project.Assemblies)
                {
                    if (cancel)
                        break;

                    using (Stream htmlStream = ResourceStream("HTML.xslt"))
                    using (Stream nunitStream = ResourceStream("NUnitXml.xslt"))
                    using (ExecutorWrapper wrapper = new ExecutorWrapper(assembly.AssemblyFilename, assembly.ConfigFilename, assembly.ShadowCopy))
                    {
                        Log.LogMessage(MessageImportance.High, "  Test assembly: {0}", assembly.AssemblyFilename);
                        Log.LogMessage(MessageImportance.High, "  xunit.dll version: {0}", wrapper.XunitVersion);

                        List<IResultXmlTransform> transforms = new List<IResultXmlTransform>();

                        foreach (KeyValuePair<string, string> kvp in assembly.Output)
                        {
                            switch (kvp.Key.ToLowerInvariant())
                            {
                                case "xml":
                                    transforms.Add(new NullTransformer(kvp.Value));
                                    break;

                                case "html":
                                    transforms.Add(new XslStreamTransformer(htmlStream, kvp.Value));
                                    break;

                                case "nunit":
                                    transforms.Add(new XslStreamTransformer(nunitStream, kvp.Value));
                                    break;

                                default:
                                    Log.LogWarning("Unknown output type: '{0}'", kvp.Key);
                                    break;
                            }
                        }

                        TestRunner runner = new TestRunner(wrapper, logger);
                        if (runner.RunAssembly(transforms) == TestRunnerResult.Failed)
                            ExitCode = -1;
                    }
                }

                StandardLogger stdLogger = logger as StandardLogger;
                if (stdLogger != null)
                {
                    Log.LogMessage(MessageImportance.High,
                                   "TOTAL Tests: {0}, Failures: {1}, Skipped: {2}, Time: {3} seconds",
                                   stdLogger.Total,
                                   stdLogger.Failed,
                                   stdLogger.Skipped,
                                   stdLogger.Time.ToString("0.000"));
                }
            }
            catch (Exception ex)
            {
                Exception e = ex;

                while (e != null)
                {
                    Log.LogError(e.GetType().FullName + ": " + e.Message);

                    foreach (string stackLine in e.StackTrace.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries))
                        Log.LogError(stackLine);

                    e = e.InnerException;
                }

                ExitCode = -1;
            }

            return ExitCode == 0;
        }
开发者ID:johnkg,项目名称:xunit,代码行数:89,代码来源:xunitproject.cs

示例2: RunAssembly

 public static TestRunState RunAssembly(TestRunner runner)
 {
     TestRunnerResult result = runner.RunAssembly();
     return TestResultMapper.Map(result);
 }
开发者ID:paulecoyote,项目名称:xunit,代码行数:5,代码来源:TdNetRunner.cs

示例3: Execute

        public override bool Execute()
        {
            try
            {
                string assemblyFilename = Assembly.GetMetadata("FullPath");

                if (WorkingFolder != null)
                    Directory.SetCurrentDirectory(WorkingFolder);

                using (ExecutorWrapper wrapper = new ExecutorWrapper(assemblyFilename, ConfigFile, ShadowCopy))
                {
                    Log.LogMessage(MessageImportance.High, "xUnit.net MSBuild runner ({0}-bit .NET {1})", IntPtr.Size * 8, Environment.Version);
                    Log.LogMessage(MessageImportance.High, "Test assembly: {0}", assemblyFilename);
                    Log.LogMessage(MessageImportance.High, "xunit.dll version: {0}", wrapper.XunitVersion);

                    IRunnerLogger logger =
                        TeamCity ? (IRunnerLogger)new TeamCityLogger(Log) :
                        Verbose ? new VerboseLogger(Log) :
                        new StandardLogger(Log);

                    List<IResultXmlTransform> transforms = new List<IResultXmlTransform>();

                    using (Stream htmlStream = ResourceStream("HTML.xslt"))
                    using (Stream nunitStream = ResourceStream("NUnitXml.xslt"))
                    {
                        if (Xml != null)
                            transforms.Add(new NullTransformer(Xml.GetMetadata("FullPath")));
                        if (Html != null)
                            transforms.Add(new XslStreamTransformer(htmlStream, Html.GetMetadata("FullPath")));
                        if (NUnitXml != null)
                            transforms.Add(new XslStreamTransformer(nunitStream, NUnitXml.GetMetadata("FullPath")));

                        TestRunner runner = new TestRunner(wrapper, logger);
                        if (runner.RunAssembly(transforms) == TestRunnerResult.Failed)
                        {
                            ExitCode = -1;
                            return false;
                        }

                        ExitCode = 0;
                        return true;
                    }
                }
            }
            catch (Exception ex)
            {
                Exception e = ex;

                while (e != null)
                {
                    Log.LogError(e.GetType().FullName + ": " + e.Message);

                    foreach (string stackLine in e.StackTrace.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries))
                        Log.LogError(stackLine);

                    e = e.InnerException;
                }

                ExitCode = -1;
                return false;
            }
        }
开发者ID:chrisortman,项目名称:coulda,代码行数:62,代码来源:xunit.cs


注:本文中的TestRunner.RunAssembly方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。