Ejemplo n.º 1
0
 public TestRun(ITestResultLogger logger, TimeSpan testTimeout, TimeSpan startupTimeout)
 {
     _logger                   = logger;
     _testTimeout              = testTimeout;
     _startupTimeout           = startupTimeout;
     _testTimeoutCheckInterval = TimeSpan.FromMilliseconds(Math.Min((int)_testTimeout.TotalMilliseconds, 1000));
 }
Ejemplo n.º 2
0
 public HttpTestCommunicator(ITestResultLogger logger, TestRun testRun, bool needsPublicIP = false)
 {
     _httpListener  = new HttpListener();
     _logger        = logger;
     _testRun       = testRun;
     _needsPublicIP = needsPublicIP;
 }
Ejemplo n.º 3
0
 public void Run(ITestResultLogger logger)
 {
     foreach (var testSuiteDir in TestSuiteDirectories)
     {
         RunTestSuite(logger, testSuiteDir);
     }
 }
Ejemplo n.º 4
0
 public ImmediateCheckAssertionVerifier(IFilter <T> items, IFilter <T> assertions, bool negateAssertion, ITestResultLogger testResultLogger)
 {
     Items             = items;
     _assertions       = assertions;
     _negateAssertion  = negateAssertion;
     _testResultLogger = testResultLogger;
 }
Ejemplo n.º 5
0
        public static string[] Discover(List <string> searchPaths, ITestResultLogger logger)
        {
            if (searchPaths.Count == 0)
            {
                searchPaths.Add(Directory.GetCurrentDirectory());
            }
            var searchDirectories = searchPaths.Where(p => !p.EndsWith(".unoproj")).ToArray();
            var explicitProjects  = searchPaths.Where(p => p.EndsWith(".unoproj")).ToArray();
            var tests             = explicitProjects.ToList();

            var notFoundProjects = explicitProjects.Where(p => !File.Exists(p)).ToList();

            if (notFoundProjects.Any())
            {
                var errorMessage = string.Format("Project{0} not found", notFoundProjects.Count() > 1 ? "s" : "");
                logger.Log(errorMessage + ": " + string.Join(", ", notFoundProjects));
                throw new Exception(errorMessage);
            }

            if (tests.Any())
            {
                logger.Log("Specified unoproj:\n " + string.Join("\n ", explicitProjects));
            }

            if (searchDirectories.Length > 0)
            {
                logger.Log("Searching for tests in:\n " + string.Join("\n ", searchDirectories));
                foreach (var searchDirectory in searchDirectories)
                {
                    tests.AddRange(Directory.GetFiles(searchDirectory, "*Test.unoproj", SearchOption.AllDirectories).Select(Path.GetFullPath));
                }
            }

            return(tests.ToArray());
        }
Ejemplo n.º 6
0
        private void RunTestSuite(ITestResultLogger logger, string directoryName)
        {
            var project = new Project(Path.Combine(directoryName, Path.GetFileName(directoryName) + ".unoproj"));

            project.MutablePackageReferences.Add(new PackageReference(project.Source, "Uno.Testing"));
            project.MutableProjectReferences.Add(new ProjectReference(project.Source, "../_Outracks.UnoTest.InternalHelpers/_Outracks.UnoTest.InternalHelpers.unoproj"));

            logger.ProjectStarting(project.Name, BuildTargets.Default.Identifier);
            var tests = new List <Test>();

            foreach (var file in Directory.GetFiles(directoryName, "*.uno").Where(x => x.EndsWith(".uno")))
            {
                var filePath = Path.GetFullPath(file);
                project.MutableIncludeItems.Clear();
                var fileName = Path.GetFileName(filePath);
                project.MutableIncludeItems.Add(new IncludeItem(project.Source, IncludeItemType.Source, fileName));

                var test = new Test(fileName);
                tests.Add(test);

                var expectations = ParseAssertComment(filePath).ToList();
                var ignores      = expectations.Where(e => e.Type == ErrorType.Ignore).ToList();
                expectations = expectations.Except(ignores).ToList();

                foreach (var ignore in ignores)
                {
                    logger.TestIgnored(new Test(ignore.ToString()));
                }

                var output           = RunBuild(project);
                var errors           = ParseOutput(output);
                var unexpectedErrors = errors.Except(expectations, new ErrorItemComparer()).ToList();
                var notGivenErrors   = expectations.Except(errors, new ErrorItemComparer()).ToList();

                foreach (var error in unexpectedErrors)
                {
                    test.Asserted(new Assertion(error.Source.FullPath, error.Source.Line, null, "(Got an unexpected error)", error.ToString(), error.Expression));
                    logger.TestAsserted(test);
                }

                foreach (var error in notGivenErrors)
                {
                    test.Asserted(new Assertion(error.Source.FullPath, error.Source.Line, null, error.ToString(), "(Missed an expected error)", error.Expression));
                    logger.TestAsserted(test);
                }

                if (!unexpectedErrors.Any() && !notGivenErrors.Any())
                {
                    test.Passed();
                    logger.TestPassed(test);
                }
            }

            logger.ProjectEnded(tests);
            logger.Log("");
        }
Ejemplo n.º 7
0
 public TestProjectRunner(string unoProj, CommandLineOptions options, ITestResultLogger logger)
 {
     _unoProj = unoProj;
     _options = options;
     _logger  = logger;
 }
Ejemplo n.º 8
0
 public TestRun(ITestResultLogger logger)
 {
     _logger = logger;
 }