示例#1
0
        public static int RunAndReturnExitCode(Options options)
        {
            Options.Singleton = options;

            var repo = new TestsRepository(Options.Singleton.TestDirRoot);

            Console.WriteLine($"Test repository root: {repo.BaseDirectory.FullName}");

            var runner  = new TestRunner(repo, new HashSet <string>(Options.Singleton.TestCases));
            var reports = runner.RunAll();

            var printer = new ReportPrinter();

            printer.Print(reports);

            var exit_code = printer.Summary.Failed > 0 ? 1 : 0;

            return(exit_code);
        }
示例#2
0
        public TestRunner(TestsRepository repository, ISet <string> selected)
        {
            if (selected.Any())
            {
                // add selected
                TestCases.AddRange(repository.GetTestCases().Where(testCase => selected.Contains(testCase.Name)));

                ISet <string> found    = new HashSet <string>(TestCases.Select(test => test.Name));
                ISet <string> notFound = new SortedSet <string>(selected.Where(test => !found.Contains(test)));
                if (notFound.Count > 0)
                {
                    throw new TestCasesNotFoundException(notFound);
                }
            }
            else
            {
                TestCases.AddRange(repository.GetTestCases());
            }

            TestCases.Sort(
                (lhs, rhs) => string.Compare(lhs.Name, rhs.Name, StringComparison.InvariantCultureIgnoreCase));
        }