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); }
public void GetAllFailedTests_WhenNotAllArePassed() { 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 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 DeserializeTestResultsFile_WhenFailedTestsPresentAndNoTestResultsFilePassed() { var consoleArgumentsProvider = Mock.Create<IConsoleArgumentsProvider>(); Mock.Arrange(() => consoleArgumentsProvider.TestResultPath).Returns("Exceptions.trx"); var fileSystemProvider = new FileSystemProvider(consoleArgumentsProvider); var testRun = fileSystemProvider.DeserializeTestRun(); Assert.AreEqual<int>(2, testRun.Results.Count()); Assert.AreEqual<string>("Failed", testRun.Results.First().outcome); Assert.IsNotNull(testRun.ResultSummary); Assert.AreEqual<int>(2, testRun.ResultSummary.Counters.total); Assert.AreEqual<int>(1, testRun.ResultSummary.Counters.passed); Assert.AreEqual<int>(1, testRun.ResultSummary.Counters.failed); Assert.AreEqual<string>("Failed", testRun.ResultSummary.outcome); }
public void SetFailedSummaryOutcome_WhenOneFailedTestPresent() { 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); microsoftTestTestRunProvider.UpdateResultsSummary(failedTestsRun); Assert.AreEqual<string>("Failed", failedTestsRun.ResultSummary.outcome); }
public void AddTwoTestArgument_WhenTwoFailedTestsPresent() { var log = Mock.Create<ILog>(); Mock.Arrange(() => log.Info(Arg.AnyString)); var consoleArgumentsProvider = Mock.Create<IConsoleArgumentsProvider>(); string 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); string additionalArguments = microsoftTestTestRunProvider.GenerateAdditionalArgumentsForFailedTestsRun(testRun.Results.ToList(), newTestResultsPath); Assert.AreEqual<string>(string.Format(@"/resultsfile:""{0}"" /test:TestConsoleExtended /test:TestConsoleExtended_Second", newTestResultsPath), additionalArguments); }
public void SetCorrectPassedCounter_WhenNoFailedTestsPresent() { 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<int>(2, failedTestsRun.ResultSummary.Counters.passed); }
public void SerializeTestResultsFile_WhenFailedTestsPresent() { var consoleArgumentsProvider = Mock.Create<IConsoleArgumentsProvider>(); string newFileName = Path.GetTempFileName(); Mock.Arrange(() => consoleArgumentsProvider.NewTestResultPath).Returns(newFileName); var fileSystemProvider = new FileSystemProvider(consoleArgumentsProvider); var testRun = fileSystemProvider.DeserializeTestRun("Exceptions.trx"); fileSystemProvider.SerializeTestRun(testRun); string originalFileContent = File.ReadAllText("Exceptions.trx"); string newFileContent = File.ReadAllText(newFileName); var originalDoc = new XmlDocument(); originalDoc.LoadXml(originalFileContent); var newDoc = new XmlDocument(); newDoc.LoadXml(newFileContent); var originalXElement = XElement.Parse(originalFileContent); var newXElement = XElement.Parse(newFileContent); XElement.DeepEquals(originalXElement, newXElement); }