public static RunThoseTests ( IEnumerable |
||
tests | IEnumerable |
|
type | ||
report | ||
log | bool | |
return | void |
// run a set of test private static FullRunDescription RunFailingTests(bool log) { var report = new FullRunDescription(); // get all test fixtures foreach (var type in typeof(GenerateErrorMessages).GetTypeInfo().Assembly.GetExportedTypes()) { try { // enumerate testmethods with expectedexception attribute with an FluentException type var tests = type.GetMethods() .Where(method => method.GetCustomAttributes(typeof(TestAttribute), false).Any()) .Where( method => { //var attributes = method.GetCustomAttributes(typeof(ExpectedExceptionAttribute), false); //if (attributes.Length == 1) //{ // var attrib = attributes[0] as ExpectedExceptionAttribute; // return attrib == null || attrib.ExpectedException == typeof(FluentCheckException); //} throw new NotImplementedException("we have to find a new way since NUnit's ExceptedException has disapeared."); }); RunnerHelper.RunThoseTests(tests, type, report, log); } catch (Exception e) { RunnerHelper.Log(string.Format("Exception while working on type:{0}" + Environment.NewLine + "{1}", type.FullName, e)); } } return(report); }
public void ScanUnitTestsAndGenerateReport() { var report = new FullRunDescription(); // get all test fixtures foreach ( var type in Assembly.GetExecutingAssembly() .GetTypes()) { try { // enumerate testmethods with expectedexception attribute with an FluentException type IEnumerable <MethodInfo> tests = type.GetMethods() .Where(method => method.GetCustomAttributes(typeof(TestAttribute), false).Length > 0) .Where( method => { object[] attributes = method.GetCustomAttributes(typeof(ExpectedExceptionAttribute), false); if (attributes.Length == 1) { var attrib = attributes[0] as ExpectedExceptionAttribute; return(attrib == null || attrib.ExpectedException == typeof(FluentAssertionException)); } return(false); }); RunnerHelper.RunThoseTests(tests, type, report); } catch (Exception e) { RunnerHelper.Log(string.Format("Exception while working on type:{0}\n{1}", type.FullName, e)); } } const string Name = "FluentReport.xml"; report.Save(Name); Debug.Write(string.Format("Report generated in {0}", Path.GetFullPath(Name))); }
// run a set of test private static FullRunDescription RunFailingTests(bool log) { var report = new FullRunDescription(); // get all test fixtures foreach (var type in Assembly.GetExecutingAssembly().GetTypes()) { try { // enumerate testmethods with expectedexception attribute with an FluentException type var tests = type.GetMethods() .Where(method => method.GetCustomAttributes(typeof(TestAttribute), false).Length > 0) .Where( method => { var attributes = method.GetCustomAttributes(typeof(ExpectedExceptionAttribute), false); if (attributes.Length == 1) { var attrib = attributes[0] as ExpectedExceptionAttribute; return(attrib == null || attrib.ExpectedException == typeof(FluentCheckException)); } return(false); }); RunnerHelper.RunThoseTests(tests, type, report, log); } catch (Exception e) { RunnerHelper.Log(string.Format("Exception while working on type:{0}\n{1}", type.FullName, e)); } } return(report); }