/// <summary> /// Executes a test method. /// </summary> /// <param name="testMethod">The test method to execute.</param> /// <returns>An array of TestResult objects that represent the outcome(s) of the test.</returns> /// <remarks>Extensions can override this method to customize running a TestMethod.</remarks> public virtual TestResult[] Execute(ITestMethod testMethod) { DataRowAttribute[] dataRows = testMethod.GetAttributes <DataRowAttribute>(false); if (dataRows == null || dataRows.Length == 0) { return(new TestResult[] { testMethod.Invoke(null) }); } return(DataTestMethodAttribute.RunDataDrivenTest(testMethod, dataRows)); }
/// <summary> /// Executes a test method. /// </summary> /// <param name="testMethod">The test method to execute.</param> /// <returns>An array of TestResult objects that represent the outcome(s) of the test.</returns> /// <remarks>Extensions can override this method to customize running a TestMethod.</remarks> public virtual TestResult[] Execute(ITestMethod testMethod) { ITestDataSource[] dataSources = testMethod.GetAttributes <Attribute>(true)?.Where(a => a is ITestDataSource).OfType <ITestDataSource>().ToArray(); if (dataSources == null || dataSources.Length == 0) { return(new TestResult[] { testMethod.Invoke(null) }); } return(DataTestMethodAttribute.RunDataDrivenTest(testMethod, dataSources)); }