public void RunTests(string resultDirectory) { var results = new List<PerformanceMetric>(); var failedRunResult = new List<Exception>(); var performanceCaseResult = new PerformanceCaseResult(); performanceCaseResult.StartTimer(); foreach (var testDefinition in _tests) { var result = Run(testDefinition); PrintSummary(result); results.AddRange(ConvertResultToMetrics(result)); if (!result.Successful) { failedRunResult.Add(result.ReportedException); } } performanceCaseResult.StopTimer(); performanceCaseResult.Metrics = results.ToArray(); Assert.False(failedRunResult.Any(), failedRunResult.Any() ? failedRunResult.First().Message : string.Empty); Assert.False(results.Count == 0, "tests returned no results"); WriteResultFiles(resultDirectory, results, performanceCaseResult); }
public void RunTests(string resultDirectory) { var results = new List <PerformanceMetric>(); var performanceCaseResult = new PerformanceCaseResult(); performanceCaseResult.StartTimer(); foreach (var testDefinition in Tests) { var result = Run(testDefinition); PrintSummary(result); results.AddRange(ConvertResultToMetrics(result)); } performanceCaseResult.StopTimer(); performanceCaseResult.Metrics = results.ToArray(); Assert.False(results.Count == 0, "tests returned no results"); var parsedData = JsonConvert.SerializeObject(performanceCaseResult, Formatting.Indented); if (!Directory.Exists(resultDirectory)) { Directory.CreateDirectory(resultDirectory); } var filename = string.Format("result_{0}.json", results.First().Scenario.Replace(' ', '_')); File.WriteAllText(Path.Combine(resultDirectory, filename), parsedData); }
public void RunTests(string resultDirectory) { var results = new List <PerformanceMetric>(); var failedRunResult = new List <Exception>(); var performanceCaseResult = new PerformanceCaseResult(); performanceCaseResult.StartTimer(); foreach (var testDefinition in _tests) { var result = Run(testDefinition); PrintSummary(result); results.AddRange(ConvertResultToMetrics(result)); if (!result.Successful) { failedRunResult.Add(result.ReportedException); } } performanceCaseResult.StopTimer(); performanceCaseResult.Metrics = results.ToArray(); Assert.False(failedRunResult.Any(), failedRunResult.Any() ? failedRunResult.First().Message : string.Empty); Assert.False(results.Count == 0, "tests returned no results"); WriteResultFiles(resultDirectory, results, performanceCaseResult); }
public void Run(string resultDirectory) { var performanceCaseResult = new PerformanceCaseResult(); performanceCaseResult.StartTimer(); var result = Run(_test); performanceCaseResult.StopTimer(); performanceCaseResult.Metrics = ConvertResultToMetrics(result).ToArray(); PrintSummary(result); if (!result.Successful) { // log the failure using an Assert that will always fail Assert.True(false, result.ReportedException.Message); } WriteResultFile(resultDirectory, _test.TestName, performanceCaseResult); }
private static void WriteResultFile(string resultDirectory, string scenario, PerformanceCaseResult performanceCaseResult) { if (!Directory.Exists(resultDirectory)) { Directory.CreateDirectory(resultDirectory); } var jsonData = JsonConvert.SerializeObject(performanceCaseResult, Formatting.Indented); var jsonFilename = $"result_{scenario}_{TestConfig.Instance.RuntimeFlavor}.json"; File.WriteAllText(Path.Combine(resultDirectory, jsonFilename), jsonData); var csvFilename = string.Format(Path.Combine(resultDirectory, "results.csv")); if (!File.Exists(csvFilename)) { File.WriteAllText(csvFilename, "StartTime,EndTime,Scenario,Metric,Unit,Value"); } foreach (var item in performanceCaseResult.Metrics) { File.AppendAllText(csvFilename, $"\r\n{performanceCaseResult.StartTime},{performanceCaseResult.EndTime},{item.Scenario},{item.Metric},{item.Unit},{item.Value}"); } }
private static void WriteResultFiles(string resultDirectory, List<PerformanceMetric> results, PerformanceCaseResult performanceCaseResult) { if (!Directory.Exists(resultDirectory)) { Directory.CreateDirectory(resultDirectory); } var jsonData = JsonConvert.SerializeObject(performanceCaseResult, Formatting.Indented); var jsonFilename = string.Format("result_{0}_{1}.json", results.First().Scenario.Replace(' ', '_'), TestConfig.Instance.RuntimeFlavor); File.WriteAllText(Path.Combine(resultDirectory, jsonFilename), jsonData); var csvFilename = Path.Combine(resultDirectory, "results.csv"); if (!File.Exists(csvFilename)) { File.WriteAllText(csvFilename, "StartTime,EndTime,Scenario,Metric,Unit,Value"); } foreach (var item in performanceCaseResult.Metrics) { File.AppendAllText(csvFilename, String.Format( "\r\n{0},{1},{2},{3},{4},{5}", performanceCaseResult.StartTime, performanceCaseResult.EndTime, item.Scenario, item.Metric, item.Unit, item.Value)); } }
private static void WriteResultFiles(string resultDirectory, List <PerformanceMetric> results, PerformanceCaseResult performanceCaseResult) { if (!Directory.Exists(resultDirectory)) { Directory.CreateDirectory(resultDirectory); } var jsonData = JsonConvert.SerializeObject(performanceCaseResult, Formatting.Indented); var jsonFilename = string.Format("result_{0}_{1}.json", results.First().Scenario.Replace(' ', '_'), TestConfig.Instance.RuntimeFlavor); File.WriteAllText(Path.Combine(resultDirectory, jsonFilename), jsonData); var csvFilename = Path.Combine(resultDirectory, "results.csv"); if (!File.Exists(csvFilename)) { File.WriteAllText(csvFilename, "StartTime,EndTime,Scenario,Metric,Unit,Value"); } foreach (var item in performanceCaseResult.Metrics) { File.AppendAllText(csvFilename, String.Format( "\r\n{0},{1},{2},{3},{4},{5}", performanceCaseResult.StartTime, performanceCaseResult.EndTime, item.Scenario, item.Metric, item.Unit, item.Value)); } }