예제 #1
0
        public void AssemblyWithMultipleTestsAndMultipleClasses()
        {
            string code = @"
                    using Xunit;

                    public class JustAPlainOldClass
                    {
                        public class Class1
                        {
                            [Fact] public void Test1() {}
                            [Fact] public void Test2() {}
                        }

                        public class Class2
                        {
                            [Fact] public void Test3() {}
                        }
                    }";

            using (MockAssembly assembly = new MockAssembly())
            {
                assembly.Compile(code);

                using (ExecutorWrapper wrapper = new ExecutorWrapper(assembly.FileName, null, false))
                    Assert.Equal(3, wrapper.GetAssemblyTestCount());
            }
        }
예제 #2
0
        public void AssemblyWithNoTests()
        {
            string code = @"
                    public class JustAPlainOldClass
                    {
                    }";

            using (MockAssembly assembly = new MockAssembly())
            {
                assembly.Compile(code);

                using (ExecutorWrapper wrapper = new ExecutorWrapper(assembly.FileName, null, false))
                    Assert.Equal(0, wrapper.GetAssemblyTestCount());
            }
        }
예제 #3
0
        static int RunProject(XunitProject project, bool teamcity, bool silent)
        {
            int totalAssemblies = 0;
            int totalTests = 0;
            int totalFailures = 0;
            int totalSkips = 0;
            double totalTime = 0;

            foreach (XunitProjectAssembly assembly in project.Assemblies)
                using (ExecutorWrapper wrapper = new ExecutorWrapper(assembly.AssemblyFilename, assembly.ConfigFilename, assembly.ShadowCopy))
                {
                    Console.WriteLine();
                    Console.WriteLine("xunit.dll:     Version {0}", wrapper.XunitVersion);
                    Console.WriteLine("Test assembly: {0}", Path.GetFullPath(assembly.AssemblyFilename));
                    Console.WriteLine();

                    try
                    {
                        List<IResultXmlTransform> transforms = TransformFactory.GetAssemblyTransforms(assembly);

                        Logger logger = teamcity
                            ? (Logger)new TeamCityLogger()
                            : new StandardLogger(silent, wrapper.GetAssemblyTestCount());

                        new TestRunner(wrapper, logger).RunAssembly(transforms);

                        ++totalAssemblies;
                        totalTests += logger.TotalTests;
                        totalFailures += logger.TotalFailures;
                        totalSkips += logger.TotalSkips;
                        totalTime += logger.TotalTime;
                    }
                    catch (ArgumentException ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }

            if (!teamcity && totalAssemblies > 1)
            {
                Console.WriteLine();
                Console.WriteLine("=== {0} total, {1} failed, {2} skipped, took {3} seconds ===",
                                   totalTests, totalFailures, totalSkips, totalTime.ToString("0.000", CultureInfo.InvariantCulture));
            }

            return totalFailures;
        }