Example #1
0
        public void UpdatePassedTests_WhenNoMatchingTestsExist()
        {
            var log = Mock.Create <ILog>();

            Mock.Arrange(() => log.Info(Arg.AnyString));
            var    consoleArgumentsProvider = Mock.Create <IConsoleArgumentsProvider>();
            string newFileName = Path.GetTempFileName();

            Mock.Arrange(() => consoleArgumentsProvider.NewTestResultPath).Returns(newFileName);
            var fileSystemProvider           = new FileSystemProvider(consoleArgumentsProvider);
            var failedTestsRun               = fileSystemProvider.DeserializeTestRun("Exceptions.trx");
            var passedTestRun                = fileSystemProvider.DeserializeTestRun("NoExceptions.trx");
            var microsoftTestTestRunProvider = new MsTestTestRunProvider(consoleArgumentsProvider, log);

            var passedTests = microsoftTestTestRunProvider.GetAllPassesTests(passedTestRun);
            var failedTests = microsoftTestTestRunProvider.GetAllNotPassedTests(failedTestsRun.Results.ToList());

            passedTests.ForEach(x => x.testId = Guid.NewGuid().ToString());

            microsoftTestTestRunProvider.UpdatePassedTests(passedTests, failedTestsRun.Results.ToList());

            var updatedFailedTests = microsoftTestTestRunProvider.GetAllNotPassedTests(failedTests);

            Assert.AreEqual <int>(1, updatedFailedTests.Count);
        }
Example #2
0
        public void GetAllFailedTests_WhenNotAllArePassed()
        {
            var log = Mock.Create <ILog>();

            Mock.Arrange(() => log.Info(Arg.AnyString));
            var consoleArgumentsProvider = Mock.Create <IConsoleArgumentsProvider>();
            var newFileName = Path.GetTempFileName();

            Mock.Arrange(() => consoleArgumentsProvider.NewTestResultPath).Returns(newFileName);
            var fileSystemProvider = new FileSystemProvider(consoleArgumentsProvider);
            var testRun            = fileSystemProvider.DeserializeTestRun("Exceptions.trx");

            var microsoftTestTestRunProvider = new MsTestTestRunProvider(consoleArgumentsProvider, log);
            var failedTests = microsoftTestTestRunProvider.GetAllNotPassedTests(testRun.Results.ToList());

            Assert.AreEqual <int>(1, failedTests.Count);
        }
        public void AddOneTestArgument_WhenOneFailedTestPresent()
        {
            var log = Mock.Create <ILog>();

            Mock.Arrange(() => log.Info(Arg.AnyString));
            var consoleArgumentsProvider = Mock.Create <IConsoleArgumentsProvider>();
            var newTestResultsPath       = Path.GetTempFileName();

            Mock.Arrange(() => consoleArgumentsProvider.ConsoleArguments).Returns(@"/resultsfile:""C:\Results.trx""");
            Mock.Arrange(() => consoleArgumentsProvider.TestResultPath).Returns(@"C:\Results.trx");
            var fileSystemProvider = new FileSystemProvider(consoleArgumentsProvider);
            var testRun            = fileSystemProvider.DeserializeTestRun("Exceptions.trx");

            var microsoftTestTestRunProvider = new MsTestTestRunProvider(consoleArgumentsProvider, log);
            var failedTests         = microsoftTestTestRunProvider.GetAllNotPassedTests(testRun.Results.ToList());
            var additionalArguments = microsoftTestTestRunProvider.GenerateAdditionalArgumentsForFailedTestsRun(failedTests, newTestResultsPath);

            Assert.AreEqual <string>(string.Format(@"/resultsfile:""{0}"" /test:TestConsoleExtended", newTestResultsPath), additionalArguments);
        }
        public void SetPassedSummaryOutcome_WhenNoFailedTestsPresentAfterRerun()
        {
            var log = Mock.Create <ILog>();

            Mock.Arrange(() => log.Info(Arg.AnyString));
            var    consoleArgumentsProvider = Mock.Create <IConsoleArgumentsProvider>();
            string newFileName = Path.GetTempFileName();

            Mock.Arrange(() => consoleArgumentsProvider.NewTestResultPath).Returns(newFileName);
            var fileSystemProvider           = new FileSystemProvider(consoleArgumentsProvider);
            var failedTestsRun               = fileSystemProvider.DeserializeTestRun("Exceptions.trx");
            var microsoftTestTestRunProvider = new MsTestTestRunProvider(consoleArgumentsProvider, log);

            var failedTests = microsoftTestTestRunProvider.GetAllNotPassedTests(failedTestsRun.Results.ToList());

            microsoftTestTestRunProvider.UpdatePassedTests(failedTests, failedTestsRun.Results.ToList());
            microsoftTestTestRunProvider.UpdateResultsSummary(failedTestsRun);

            Assert.AreEqual <string>("Passed", failedTestsRun.ResultSummary.outcome);
        }