Esempio n. 1
0
        static int RunProject(XunitProject project, bool teamcity, bool silent, string[] args)
        {
            var defaultArgs = args.Aggregate((a, b) => a + " " + b);

            var mate = new MultiAssemblyTestEnvironment();
            foreach (XunitProjectAssembly assembly in project.Assemblies)
            {
                TestAssembly testAssembly = mate.Load(assembly.AssemblyFilename, assembly.ConfigFilename, assembly.ShadowCopy);
                var methods = new List<TestMethod>(testAssembly.EnumerateTestMethods(project.Filters.Filter));
                var methodsCount = methods.Count;

                ParallelXunitCommandLine.DeleteResultFiles(assembly.AssemblyFilename);

                using (var waiter = new ProcessWaiter())
                {
                    waiter.DefaultArgs = defaultArgs;
                    waiter.TeamCity = teamcity;
                    waiter.Silent = silent;

                    Console.WriteLine("Running with {0} threads.", waiter.MaximumNumberOfProcesses);
                    Console.WriteLine("Total number of tests: {0}.", methodsCount);

                    IParallelTestMethodRunnerCallback callback = CreateCallback(teamcity, silent, methodsCount);
                    callback.ParentAssemblyStart(testAssembly);

                    TestBatch batch;
                    var batcher = new TestMethodBatcher(methodsCount);
                    while ((batch = batcher.GetNextBatch()).Size > 0)
                    {
                        waiter.StartProcess(batch);
                    }

                    if (!teamcity)
                    {
                        waiter.PrintSummary();
                    }
                    else
                    {
                        waiter.WaitForAllProcesses();
                    }

                    var testResult = ParallelXunitCommandLine.AggregateTestResults(assembly.AssemblyFilename);
                    callback.ParentAssemblyFinished(testAssembly, testResult.Total, testResult.Failed, testResult.Skiped);

                    mate.Unload(testAssembly);
                }
            }

            return 0;
        }
Esempio n. 2
0
        static int RunProject(XunitProject project, bool teamcity, bool silent, string[] args)
        {
            var defaultArgs = args.Aggregate((a, b) => a + " " + b);

            var mate = new MultiAssemblyTestEnvironment();
            foreach (XunitProjectAssembly assembly in project.Assemblies)
            {
                TestAssembly testAssembly = mate.Load(assembly.AssemblyFilename, assembly.ConfigFilename, assembly.ShadowCopy);
                var methods = new List<TestMethod>(testAssembly.EnumerateTestMethods(project.Filters.Filter));

                var batcher = new TestMethodBatcher(methods.Count);

                var waiter = new ProcessWaiter();
                waiter.DefaultArgs = defaultArgs;
                waiter.TeamCity = teamcity;
                waiter.Silent = silent;

                Console.WriteLine("Running with {0} threads.", waiter.MaximumNumberOfProcesses);
                Console.WriteLine("Total number of tests: {0}.", methods.Count);

                TestBatch batch;
                while ((batch = batcher.GetNextBatch()).Size > 0)
                {
                    waiter.StartProcess(batch);
                }

                waiter.PrintSummary();

                mate.Unload(testAssembly);
            }

            return 0;
        }