public TestInfo(Type className, MethodInfo method, IEnumerable <MethodInfo> beforeMethods, IEnumerable <MethodInfo> afterMethods, TestClassReport classReport) { ClassName = className; Method = method; BeforeMethods = beforeMethods; AfterMethods = afterMethods; ClassReport = classReport; }
/// <summary> /// Runs tests in the class and writes result into the report /// </summary> private static void RunTests(Type className) { ExecuteStaticMethods(className, typeof(BeforeClassAttribute)); var classReport = new TestClassReport(className.Assembly.FullName.Split(' ')[0].TrimEnd(','), className.Name); report.Enqueue(classReport); var tests = new ConcurrentQueue <TestInfo>(); var beforeMethods = GetMethodsWithAttribute(className, typeof(BeforeAttribute)); var afterMethods = GetMethodsWithAttribute(className, typeof(AfterAttribute)); foreach (var method in GetMethodsWithAttribute(className, typeof(TestAttribute))) { tests.Enqueue(new TestInfo(className, method, beforeMethods, afterMethods, classReport)); } Parallel.ForEach(tests, RunTest); ExecuteStaticMethods(className, typeof(AfterClassAttribute)); }