// src\xunit.execution\Sdk\Frameworks\XunitTestFrameworkDiscoverer.cs protected override bool FindTestsForMethod(ITestMethod testMethod, bool includeSourceInformation, IMessageBus messageBus, ITestFrameworkDiscoveryOptions discoveryOptions) { var factAttribute = testMethod.Method.GetCustomAttributes(typeof(FactAttribute)).FirstOrDefault(); if (factAttribute == null) { return(true); } var testCaseDiscovererAttribute = factAttribute.GetCustomAttributes(typeof(XunitTestCaseDiscovererAttribute)).FirstOrDefault(); if (testCaseDiscovererAttribute == null) { return(true); } var args = testCaseDiscovererAttribute.GetConstructorArguments().Cast <string>().ToList(); Type discovererType = typeof(FactDiscoverer).Assembly.GetType(args[0]); if (discovererType == null) { return(true); } var discoverer = GetDiscoverer(discovererType); if (discoverer == null) { return(true); } var methodDisplay = discoveryOptions.MethodDisplayOrDefault(); var testAttribute = testMethod.TestClass.Class.GetCustomAttributes(typeof(KuduXunitTestClassAttribute)).FirstOrDefault(); foreach (var testCase in discoverer.Discover(discoveryOptions, testMethod, factAttribute).OfType <XunitTestCase>()) { IXunitTestCase kuduTestCase; if (testCase is ExecutionErrorTestCase) { kuduTestCase = testCase; } else if (testCase is XunitTheoryTestCase) { kuduTestCase = new KuduXunitTheoryTestCase(DiagnosticMessageSink, methodDisplay, testCase.TestMethod, testAttribute); } else { kuduTestCase = new KuduXunitTestCase(DiagnosticMessageSink, methodDisplay, testCase.TestMethod, testCase.TestMethodArguments, testAttribute); } if (!ReportDiscoveredTestCase(kuduTestCase, includeSourceInformation, messageBus)) { return(false); } } return(true); }
// src\xunit.execution\Sdk\Frameworks\XunitTestFrameworkDiscoverer.cs protected override bool FindTestsForMethod(ITestMethod testMethod, bool includeSourceInformation, IMessageBus messageBus, ITestFrameworkDiscoveryOptions discoveryOptions) { var factAttribute = testMethod.Method.GetCustomAttributes(typeof(FactAttribute)).FirstOrDefault(); if (factAttribute == null) return true; var testCaseDiscovererAttribute = factAttribute.GetCustomAttributes(typeof(XunitTestCaseDiscovererAttribute)).FirstOrDefault(); if (testCaseDiscovererAttribute == null) return true; var args = testCaseDiscovererAttribute.GetConstructorArguments().Cast<string>().ToList(); Type discovererType = typeof(FactDiscoverer).Assembly.GetType(args[0]); if (discovererType == null) return true; var discoverer = GetDiscoverer(discovererType); if (discoverer == null) return true; // in non-private env, we will skip test marked with PrivateOnly. var methodAttribute = testMethod.Method.GetCustomAttributes(typeof(KuduXunitTestAttribute)).FirstOrDefault(); if (methodAttribute != null && !_privateEnv && methodAttribute.GetNamedArgument<bool>("PrivateOnly")) return true; var methodDisplay = discoveryOptions.MethodDisplayOrDefault(); var testAttribute = testMethod.TestClass.Class.GetCustomAttributes(typeof(KuduXunitTestClassAttribute)).FirstOrDefault(); foreach (var testCase in discoverer.Discover(discoveryOptions, testMethod, factAttribute).OfType<XunitTestCase>()) { IXunitTestCase kuduTestCase; if (testCase is ExecutionErrorTestCase) kuduTestCase = testCase; else if (testCase is XunitTheoryTestCase) kuduTestCase = new KuduXunitTheoryTestCase(DiagnosticMessageSink, methodDisplay, testCase.TestMethod, testAttribute); else kuduTestCase = new KuduXunitTestCase(DiagnosticMessageSink, methodDisplay, testCase.TestMethod, testCase.TestMethodArguments, testAttribute); if (!ReportDiscoveredTestCase(kuduTestCase, includeSourceInformation, messageBus)) return false; } return true; }