diff --git a/UnityPerformanceBenchmarkReporter/PerformanceTestRunProcessor.cs b/UnityPerformanceBenchmarkReporter/PerformanceTestRunProcessor.cs index 5336ed6..36e1787 100644 --- a/UnityPerformanceBenchmarkReporter/PerformanceTestRunProcessor.cs +++ b/UnityPerformanceBenchmarkReporter/PerformanceTestRunProcessor.cs @@ -189,7 +189,7 @@ public PerformanceTestRunResult CreateTestRunResult(PerformanceTestRun runResult TestSuite = runResults.TestSuite, StartTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddMilliseconds( - runResults.StartTime), + runResults.StartTime).ToLocalTime(), TestResults = testResults, PlayerSystemInfo = runResults.PlayerSystemInfo, EditorVersion = runResults.EditorVersion, diff --git a/UnityPerformanceBenchmarkReporterTests/PerformanceBenchmarkTests.cs b/UnityPerformanceBenchmarkReporterTests/PerformanceBenchmarkTests.cs index a4d3600..c657d0b 100644 --- a/UnityPerformanceBenchmarkReporterTests/PerformanceBenchmarkTests.cs +++ b/UnityPerformanceBenchmarkReporterTests/PerformanceBenchmarkTests.cs @@ -48,6 +48,26 @@ public void Verify_AddPerformanceTestRunResults() Assert.IsTrue(performanceTestRunResults.Count > 0); } + [Test] + public void Verify_AddPerformanceTestRunResultsV2() + { + // Arrange + var resultXmlFilePath = EnsureFullPath("results_v2.xml"); + var args = new[] { string.Format("--testresultsxmlsource={0}", resultXmlFilePath) }; + optionsParser.ParseOptions(PerformanceBenchmark, args); + + // Act + PerformanceBenchmark.AddPerformanceTestRunResults(testResultXmlParser, performanceTestRunResults, testResults, new List()); + + // Assert + Assert.IsTrue(PerformanceBenchmark.ResultFilesExist); + AssertCorrectResultXmlFilePaths(new[] { resultXmlFilePath }); + Assert.NotNull(testResults); + Assert.IsTrue(testResults.Count > 0); + Assert.NotNull(performanceTestRunResults); + Assert.IsTrue(performanceTestRunResults.Count > 0); + } + [Test] public void Verify_AddPerformanceTestRunResults_TwoResultFiles() { @@ -73,6 +93,31 @@ public void Verify_AddPerformanceTestRunResults_TwoResultFiles() Assert.IsTrue(performanceTestRunResults.Count > 0); } + [Test] + public void Verify_AddPerformanceTestRunResults_OneV1ResultFiles_OneV2ResultFiles() + { + // Arrange + var resultXmlFilePath = EnsureFullPath("results.xml"); + var resultFileName2 = EnsureFullPath("results_v2.xml"); + var args = new[] + { + string.Format("--testresultsxmlsource={0}", resultXmlFilePath), + string.Format("--testresultsxmlsource={0}", resultFileName2) + }; + optionsParser.ParseOptions(PerformanceBenchmark, args); + + // Act + PerformanceBenchmark.AddPerformanceTestRunResults(testResultXmlParser, performanceTestRunResults, testResults, new List()); + + // Assert + Assert.IsTrue(PerformanceBenchmark.ResultFilesExist); + AssertCorrectResultXmlFilePaths(new[] { resultXmlFilePath, resultFileName2 }); + Assert.NotNull(testResults); + Assert.IsTrue(testResults.Count > 0); + Assert.NotNull(performanceTestRunResults); + Assert.IsTrue(performanceTestRunResults.Count > 0); + } + [Test] public void Verify_AddPerformanceTestRunResults_OneResultFiles_OneResultDirectory() { @@ -81,8 +126,8 @@ public void Verify_AddPerformanceTestRunResults_OneResultFiles_OneResultDirector var resultsXmlDir = EnsureFullPath("Results"); var args = new[] { - string.Format("--testresultsxmlsource={0}", resultXmlFilePath), - string.Format("--testresultsxmlsource={0}", resultsXmlDir) + string.Format("--testresultsxmlsource={0}", resultXmlFilePath), + string.Format("--testresultsxmlsource={0}", resultsXmlDir) }; optionsParser.ParseOptions(PerformanceBenchmark, args); @@ -126,11 +171,11 @@ public void Verify_AddBaselinePerformanceTestRunResults() } [Test] - public void Verify_AddBaselinePerformanceTestRunResultsDirectory() + public void Verify_AddBaselinePerformanceTestRunResults_V2BaselineFile() { // Arrange var resultXmlFilePath = EnsureFullPath("results.xml"); - var baselineXmlFilePath = EnsureFullPath("baseline.xml"); + var baselineXmlFilePath = EnsureFullPath("baseline_v2.xml"); var args = new[] { string.Format("--testresultsxmlsource={0}", resultXmlFilePath), @@ -143,6 +188,34 @@ public void Verify_AddBaselinePerformanceTestRunResultsDirectory() // Assert Assert.IsTrue(PerformanceBenchmark.BaselineResultFilesExist); + AssertCorrectBaselineXmlFilePaths(new[] { baselineXmlFilePath }); + AssertCorrectResultXmlFilePaths(new[] { resultXmlFilePath }); + Assert.NotNull(baselineTestResults); + Assert.IsTrue(baselineTestResults.Count > 0); + Assert.NotNull(baselinePerformanceTestRunResults); + Assert.IsTrue(baselinePerformanceTestRunResults.Count > 0); + } + + [Test] + public void Verify_AddBaselinePerformanceTestRunResultsDirectory() + { + // Arrange + var resultsXmlDir = EnsureFullPath("Results"); + var baselineXmlFilePath = EnsureFullPath("baseline.xml"); + var args = new[] + { + string.Format("--testresultsxmlsource={0}", resultsXmlDir), + string.Format("--baselinexmlsource={0}", baselineXmlFilePath) + }; + optionsParser.ParseOptions(PerformanceBenchmark, args); + + // Act + PerformanceBenchmark.AddBaselinePerformanceTestRunResults(testResultXmlParser, baselinePerformanceTestRunResults, baselineTestResults); + + // Assert + Assert.IsTrue(PerformanceBenchmark.BaselineResultFilesExist); + AssertCorrectBaselineXmlFilePaths(new[] { baselineXmlFilePath }); + AssertCorrectResultsXmlDirectoryPaths(new[] { resultsXmlDir }); Assert.NotNull(baselineTestResults); Assert.IsTrue(baselineTestResults.Count > 0); Assert.NotNull(baselinePerformanceTestRunResults); @@ -157,9 +230,9 @@ public void Verify_Verify_AddBaselineAndNonBaselinePerformanceTestRunResults() var baselineXmlFilePath = EnsureFullPath("baseline.xml"); var args = new[] { - string.Format("--testresultsxmlsource={0}", resultXmlFilePath), - string.Format("--baselinexmlsource={0}", baselineXmlFilePath) - }; + string.Format("--testresultsxmlsource={0}", resultXmlFilePath), + string.Format("--baselinexmlsource={0}", baselineXmlFilePath) + }; optionsParser.ParseOptions(PerformanceBenchmark, args); // Act diff --git a/UnityPerformanceBenchmarkReporterTests/TestData/Results/results_v2.xml b/UnityPerformanceBenchmarkReporterTests/TestData/Results/results_v2.xml new file mode 100644 index 0000000..796634f --- /dev/null +++ b/UnityPerformanceBenchmarkReporterTests/TestData/Results/results_v2.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/UnityPerformanceBenchmarkReporterTests/TestData/baseline_v2.xml b/UnityPerformanceBenchmarkReporterTests/TestData/baseline_v2.xml new file mode 100644 index 0000000..8b5f59c --- /dev/null +++ b/UnityPerformanceBenchmarkReporterTests/TestData/baseline_v2.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/UnityPerformanceBenchmarkReporterTests/TestData/results_v2.xml b/UnityPerformanceBenchmarkReporterTests/TestData/results_v2.xml new file mode 100644 index 0000000..796634f --- /dev/null +++ b/UnityPerformanceBenchmarkReporterTests/TestData/results_v2.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/UnityPerformanceBenchmarkReporterTests/UnityPerformanceBenchmarkReporterTests.csproj b/UnityPerformanceBenchmarkReporterTests/UnityPerformanceBenchmarkReporterTests.csproj index be96621..54578b8 100644 --- a/UnityPerformanceBenchmarkReporterTests/UnityPerformanceBenchmarkReporterTests.csproj +++ b/UnityPerformanceBenchmarkReporterTests/UnityPerformanceBenchmarkReporterTests.csproj @@ -17,9 +17,6 @@ - - PreserveNewest - PreserveNewest @@ -44,6 +41,15 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + \ No newline at end of file