public void UpdateTestDurations_SameTestsInDifferentExecutables_DurationsAreWrittenAndReadCorrectly() { string tempFile = Path.GetTempFileName(); string tempFile2 = Path.GetTempFileName(); List<Model.TestResult> testResults = new List<Model.TestResult> { TestDataCreator.ToTestResult("TestSuite1.Test1", Model.TestOutcome.Passed, 3, tempFile), TestDataCreator.ToTestResult("TestSuite1.Test1", Model.TestOutcome.Failed, 4, tempFile2) }; var serializer = new TestDurationSerializer(); serializer.UpdateTestDurations(testResults); string durationsFile1 = GetDurationsFile(serializer, tempFile); File.Exists(durationsFile1).Should().BeTrue(); string durationsFile2 = GetDurationsFile(serializer, tempFile2); File.Exists(durationsFile2).Should().BeTrue(); IDictionary<Model.TestCase, int> durations = serializer.ReadTestDurations(testResults.Select(tr => tr.TestCase)); durations.Count.Should().Be(2); durations.Should().ContainKey(testResults[0].TestCase); durations[testResults[0].TestCase].Should().Be(3); durations.Should().ContainKey(testResults[1].TestCase); durations[testResults[1].TestCase].Should().Be(4); File.Delete(durationsFile1); File.Delete(durationsFile2); }
public void UpdateTestDurations_SameTestsInDifferentExecutables_DurationsAreWrittenAndReadCorrectly() { string tempFile = Path.GetTempFileName(); string tempFile2 = Path.GetTempFileName(); List <Model.TestResult> testResults = new List <Model.TestResult> { TestDataCreator.ToTestResult("TestSuite1.Test1", Model.TestOutcome.Passed, 3, tempFile), TestDataCreator.ToTestResult("TestSuite1.Test1", Model.TestOutcome.Failed, 4, tempFile2) }; var serializer = new TestDurationSerializer(); serializer.UpdateTestDurations(testResults); string durationsFile1 = GetDurationsFile(serializer, tempFile); durationsFile1.AsFileInfo().Should().Exist(); string durationsFile2 = GetDurationsFile(serializer, tempFile2); durationsFile2.AsFileInfo().Should().Exist(); IDictionary <Model.TestCase, int> durations = serializer.ReadTestDurations(testResults.Select(tr => tr.TestCase)); durations.Should().HaveCount(2); durations.Should().ContainKey(testResults[0].TestCase); durations[testResults[0].TestCase].Should().Be(3); durations.Should().ContainKey(testResults[1].TestCase); durations[testResults[1].TestCase].Should().Be(4); File.Delete(durationsFile1); File.Delete(durationsFile2); }
public void UpdateTestDurations_SimpleTests_DurationsAreWrittenAndReadCorrectly() { string tempFile = Path.GetTempFileName(); List <Model.TestResult> testResults = new List <Model.TestResult> { TestDataCreator.ToTestResult("TestSuite1.Test1", Model.TestOutcome.Passed, 3, tempFile), TestDataCreator.ToTestResult("TestSuite1.SkippedTest", Model.TestOutcome.Skipped, 1, tempFile) }; var serializer = new TestDurationSerializer(); serializer.UpdateTestDurations(testResults); string durationsFile = GetDurationsFile(serializer, tempFile); durationsFile.AsFileInfo().Should().Exist(); IDictionary <Model.TestCase, int> durations = serializer.ReadTestDurations(testResults.Select(tr => tr.TestCase)); durations.Count.Should().Be(1); durations.Should().ContainKey(testResults[0].TestCase); durations[testResults[0].TestCase].Should().Be(3); durations.Should().NotContainKey(testResults[1].TestCase); File.Delete(durationsFile); }
public void UpdateTestDurations_SameTestsInDifferentExecutables_DurationsAreWrittenAndReadCorrectly() { string tempFile = Path.GetTempFileName(); string tempFile2 = Path.GetTempFileName(); List <Model.TestResult> testResults = new List <Model.TestResult> { ToTestResult("TestSuite1.Test1", Model.TestOutcome.Passed, 3, tempFile), ToTestResult("TestSuite1.Test1", Model.TestOutcome.Failed, 4, tempFile2) }; var serializer = new TestDurationSerializer(); serializer.UpdateTestDurations(testResults); string durationsFile1 = GetDurationsFile(serializer, tempFile); Assert.IsTrue(File.Exists(durationsFile1)); string durationsFile2 = GetDurationsFile(serializer, tempFile2); Assert.IsTrue(File.Exists(durationsFile2)); IDictionary <Model.TestCase, int> durations = serializer.ReadTestDurations(testResults.Select(tr => tr.TestCase)); Assert.AreEqual(2, durations.Count); Assert.IsTrue(durations.ContainsKey(testResults[0].TestCase)); Assert.AreEqual(3, durations[testResults[0].TestCase]); Assert.IsTrue(durations.ContainsKey(testResults[1].TestCase)); Assert.AreEqual(4, durations[testResults[1].TestCase]); File.Delete(durationsFile1); File.Delete(durationsFile2); }
public void UpdateTestDurations_SimpleTests_DurationsAreWrittenAndReadCorrectly() { string tempFile = Path.GetTempFileName(); List <Model.TestResult> testResults = new List <Model.TestResult> { ToTestResult("TestSuite1.Test1", Model.TestOutcome.Passed, 3, tempFile), ToTestResult("TestSuite1.SkippedTest", Model.TestOutcome.Skipped, 1, tempFile) }; var serializer = new TestDurationSerializer(); serializer.UpdateTestDurations(testResults); string durationsFile = GetDurationsFile(serializer, tempFile); Assert.IsTrue(File.Exists(durationsFile)); IDictionary <Model.TestCase, int> durations = serializer.ReadTestDurations(testResults.Select(tr => tr.TestCase)); Assert.AreEqual(1, durations.Count); Assert.IsTrue(durations.ContainsKey(testResults[0].TestCase)); Assert.AreEqual(3, durations[testResults[0].TestCase]); Assert.IsFalse(durations.ContainsKey(testResults[1].TestCase)); File.Delete(durationsFile); }
public void UpdateTestDurations_SingleTest_DurationIsUpdatedCorrectly() { string tempFile = Path.GetTempFileName(); List <Model.TestResult> testResults = new List <Model.TestResult> { TestDataCreator.ToTestResult("TestSuite1.Test1", Model.TestOutcome.Passed, 3, tempFile) }; var serializer = new TestDurationSerializer(); serializer.UpdateTestDurations(testResults); IDictionary <Model.TestCase, int> durations = serializer.ReadTestDurations(testResults.Select(tr => tr.TestCase)); durations[testResults[0].TestCase].Should().Be(3); testResults[0].Duration = TimeSpan.FromMilliseconds(4); serializer.UpdateTestDurations(testResults); durations = serializer.ReadTestDurations(testResults.Select(tr => tr.TestCase)); durations.Should().HaveCount(1); durations.Should().ContainKey(testResults[0].TestCase); durations[testResults[0].TestCase].Should().Be(4); File.Delete(GetDurationsFile(serializer, tempFile)); }
public void UpdateTestDurations_SingleTest_DurationIsUpdatedCorrectly() { string tempFile = Path.GetTempFileName(); List <Model.TestResult> testResults = new List <Model.TestResult> { ToTestResult("TestSuite1.Test1", Model.TestOutcome.Passed, 3, tempFile) }; var serializer = new TestDurationSerializer(); serializer.UpdateTestDurations(testResults); IDictionary <Model.TestCase, int> durations = serializer.ReadTestDurations(testResults.Select(tr => tr.TestCase)); Assert.AreEqual(3, durations[testResults[0].TestCase]); testResults[0].Duration = TimeSpan.FromMilliseconds(4); serializer.UpdateTestDurations(testResults); durations = serializer.ReadTestDurations(testResults.Select(tr => tr.TestCase)); Assert.AreEqual(1, durations.Count); Assert.IsTrue(durations.ContainsKey(testResults[0].TestCase)); Assert.AreEqual(4, durations[testResults[0].TestCase]); File.Delete(GetDurationsFile(serializer, tempFile)); }
public void ReadTestDurations_DurationFileWithoutCurrentTest_EmptyDictionary() { string tempFile = Path.GetTempFileName(); List <Model.TestResult> testResults = new List <Model.TestResult> { TestDataCreator.ToTestResult("TestSuite1.Test1", Model.TestOutcome.None, 3, tempFile) }; var serializer = new TestDurationSerializer(); serializer.UpdateTestDurations(testResults); IDictionary <Model.TestCase, int> durations = serializer.ReadTestDurations( new Model.TestCase("TestSuite1.Test2", tempFile, "TestSuite1.Test2", "", 0).Yield()); durations.Should().NotBeNull(); durations.Should().BeEmpty(); File.Delete(GetDurationsFile(serializer, tempFile)); }
public void UpdateTestDurations_SingleTest_DurationIsUpdatedCorrectly() { string tempFile = Path.GetTempFileName(); List<Model.TestResult> testResults = new List<Model.TestResult> { TestDataCreator.ToTestResult("TestSuite1.Test1", Model.TestOutcome.Passed, 3, tempFile) }; var serializer = new TestDurationSerializer(); serializer.UpdateTestDurations(testResults); IDictionary<Model.TestCase, int> durations = serializer.ReadTestDurations(testResults.Select(tr => tr.TestCase)); durations[testResults[0].TestCase].Should().Be(3); testResults[0].Duration = TimeSpan.FromMilliseconds(4); serializer.UpdateTestDurations(testResults); durations = serializer.ReadTestDurations(testResults.Select(tr => tr.TestCase)); durations.Count.Should().Be(1); durations.Should().ContainKey(testResults[0].TestCase); durations[testResults[0].TestCase].Should().Be(4); File.Delete(GetDurationsFile(serializer, tempFile)); }
// ReSharper disable once UnusedParameter.Local private void RunTestsFromExecutable(string executable, string workingDir, IEnumerable<TestCase> allTestCases, IEnumerable<TestCase> testCasesToRun, string baseDir, string userParameters, bool isBeingDebugged, IDebuggedProcessLauncher debuggedLauncher) { string resultXmlFile = Path.GetTempFileName(); var serializer = new TestDurationSerializer(); var generator = new CommandLineGenerator(allTestCases, testCasesToRun, executable.Length, userParameters, resultXmlFile, _testEnvironment); foreach (CommandLineGenerator.Args arguments in generator.GetCommandLines()) { if (_canceled) { break; } _frameworkReporter.ReportTestsStarted(arguments.TestCases); List<string> consoleOutput = new TestProcessLauncher(_testEnvironment, isBeingDebugged).GetOutputOfCommand(workingDir, executable, arguments.CommandLine, _testEnvironment.Options.PrintTestOutput && !_testEnvironment.Options.ParallelTestExecution, false, debuggedLauncher); IEnumerable<TestResult> results = CollectTestResults(arguments.TestCases, resultXmlFile, consoleOutput, baseDir); Stopwatch stopwatch = Stopwatch.StartNew(); _frameworkReporter.ReportTestResults(results); stopwatch.Stop(); _testEnvironment.DebugInfo($"Reported {results.Count()} test results to VS, executable: '{executable}', duration: {stopwatch.Elapsed}"); serializer.UpdateTestDurations(results); } }
public void ReadTestDurations_DurationFileWithoutCurrentTest_EmptyDictionary() { string tempFile = Path.GetTempFileName(); List<Model.TestResult> testResults = new List<Model.TestResult> { TestDataCreator.ToTestResult("TestSuite1.Test1", Model.TestOutcome.None, 3, tempFile) }; var serializer = new TestDurationSerializer(); serializer.UpdateTestDurations(testResults); IDictionary<Model.TestCase, int> durations = serializer.ReadTestDurations( new Model.TestCase("TestSuite1.Test2", tempFile, "TestSuite1.Test2", "", 0).Yield()); durations.Should().NotBeNull(); durations.Count.Should().Be(0); File.Delete(GetDurationsFile(serializer, tempFile)); }