static async Task Run(Testing[] testings, Options options) { Stopwatch timer = new Stopwatch(); for (int i = 0; i < testings.Length; ++i) { if (i != 0) { Console.WriteLine("================================================================"); } Testing testing = testings[i]; Console.WriteLine("--------TestCase {0} Enter", string.IsNullOrEmpty(testing.Name) ? testing.Path : testing.Name); try { for (int j = 0; j < testing.Prepares.Length; ++j) { Func <Task> action = testing.Prepares[j]; await action(); } Thread.Sleep(10); GC.Collect(); timer.Restart(); await testing.Action(options.Count); timer.Stop(); } catch (Exception e) { Console.WriteLine("Catch Exception : {0}\n{1}", e.Message, e.StackTrace); if (options.StopOnError) { return; } continue; } if ((options.Performance.HasValue && options.Performance.Value) || (!options.Performance.HasValue && options.Count > 1)) { Console.WriteLine("--------TestCase {0} Exit, Cost {1} ms", string.IsNullOrEmpty(testing.Name) ? testing.Path : testing.Name, timer.ElapsedMilliseconds); } else { Console.WriteLine("--------TestCase {0} Exit", string.IsNullOrEmpty(testing.Name) ? testing.Path : testing.Name); } } }