本文整理汇总了C#中ITestFrameworkDiscoveryOptions类的典型用法代码示例。如果您正苦于以下问题:C# ITestFrameworkDiscoveryOptions类的具体用法?C# ITestFrameworkDiscoveryOptions怎么用?C# ITestFrameworkDiscoveryOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ITestFrameworkDiscoveryOptions类属于命名空间,在下文中一共展示了ITestFrameworkDiscoveryOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Discover
public IEnumerable<IXunitTestCase> Discover(
ITestFrameworkDiscoveryOptions discoveryOptions,
ITestMethod testMethod,
IAttributeInfo factAttribute)
{
var skipReason = EvaluateSkipConditions(testMethod);
var isTheory = false;
IXunitTestCaseDiscoverer innerDiscoverer;
if (testMethod.Method.GetCustomAttributes(typeof(TheoryAttribute)).Any())
{
isTheory = true;
innerDiscoverer = new TheoryDiscoverer(_diagnosticMessageSink);
}
else
{
innerDiscoverer = new FactDiscoverer(_diagnosticMessageSink);
}
var testCases = innerDiscoverer
.Discover(discoveryOptions, testMethod, factAttribute)
.Select(testCase => new SkipReasonTestCase(isTheory, skipReason, testCase));
return testCases;
}
示例2: Find
/// <summary>
/// Starts the process of finding all tests in an assembly.
/// </summary>
/// <param name="discoverer">The discoverer.</param>
/// <param name="includeSourceInformation">Whether to include source file information, if possible.</param>
/// <param name="discoveryMessageSink">The message sink to report results back to.</param>
/// <param name="discoveryOptions">The options used by the test framework during discovery.</param>
public static void Find(this ITestFrameworkDiscoverer discoverer,
bool includeSourceInformation,
IMessageSinkWithTypes discoveryMessageSink,
ITestFrameworkDiscoveryOptions discoveryOptions)
{
discoverer.Find(includeSourceInformation, MessageSinkAdapter.Wrap(discoveryMessageSink), discoveryOptions);
}
示例3: Discover
public IEnumerable<IXunitTestCase> Discover (ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
{
var defaultMethodDisplay = discoveryOptions.MethodDisplayOrDefault ();
if (testMethod.Method.GetParameters ().Any ()) {
return new IXunitTestCase[] {
new ExecutionErrorTestCase (messageSink, defaultMethodDisplay, testMethod, "[VsixFact] methods are not allowed to have parameters.")
};
} else {
var vsVersions = VsVersions.GetFinalVersions(testMethod.GetComputedProperty<string[]>(factAttribute, SpecialNames.VsixAttribute.VisualStudioVersions));
// Process VS-specific traits.
var suffix = testMethod.GetComputedArgument<string>(factAttribute, SpecialNames.VsixAttribute.RootSuffix) ?? "Exp";
var newInstance = testMethod.GetComputedArgument<bool?>(factAttribute, SpecialNames.VsixAttribute.NewIdeInstance);
var timeout = testMethod.GetComputedArgument<int?>(factAttribute, SpecialNames.VsixAttribute.TimeoutSeconds).GetValueOrDefault(XunitExtensions.DefaultTimeout);
var testCases = new List<IXunitTestCase>();
// Add invalid VS versions.
testCases.AddRange (vsVersions
.Where (v => !VsVersions.InstalledVersions.Contains (v))
.Select (v => new ExecutionErrorTestCase (messageSink, defaultMethodDisplay, testMethod,
string.Format ("Cannot execute test for specified {0}={1} because there is no VSSDK installed for that version.", SpecialNames.VsixAttribute.VisualStudioVersions, v))));
testCases.AddRange (vsVersions
.Where (v => VsVersions.InstalledVersions.Contains (v))
.Select (v => new VsixTestCase (messageSink, defaultMethodDisplay, testMethod, v, suffix, newInstance, timeout)));
return testCases;
}
}
示例4:
public IEnumerable<IXunitTestCase> Discover
( ITestFrameworkDiscoveryOptions discoveryOptions
, ITestMethod testMethod
, IAttributeInfo factAttribute
)
{
var inv = InvariantTestCase.InvariantFromMethod(testMethod);
return
inv == null
? new[]
{ new InvariantTestCase
( MessageSink
, TestMethodDisplay.Method
, testMethod
, null
)
}
: inv.AsSeq().Select
( i =>
new InvariantTestCase
( MessageSink
, TestMethodDisplay.Method
, testMethod
, i
)
);
}
示例5: Discover
public IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
{
var defaultMethodDisplay = discoveryOptions.MethodDisplayOrDefault();
return factAttribute.GetNamedArgument<string>("Skip") != null
? new[] { new XunitTestCase(_diagnosticMessageSink, defaultMethodDisplay, testMethod) }
: new XunitTestCase[] { new ScenarioTestCase(_diagnosticMessageSink, defaultMethodDisplay, testMethod) };
}
示例6: FindTestsForMethod
/// <summary>
/// Finds the tests on a test method.
/// </summary>
/// <param name="testMethod">The test method.</param>
/// <param name="includeSourceInformation">Set to <c>true</c> to indicate that source information should be included.</param>
/// <param name="messageBus">The message bus to report discovery messages to.</param>
/// <param name="discoveryOptions">The options used by the test framework during discovery.</param>
/// <returns>Return <c>true</c> to continue test discovery, <c>false</c>, otherwise.</returns>
protected virtual bool FindTestsForMethod(ITestMethod testMethod, bool includeSourceInformation, IMessageBus messageBus, ITestFrameworkDiscoveryOptions discoveryOptions)
{
var factAttributes = testMethod.Method.GetCustomAttributes(typeof(FactAttribute)).CastOrToList();
if (factAttributes.Count > 1)
{
var message = string.Format("Test method '{0}.{1}' has multiple [Fact]-derived attributes", testMethod.TestClass.Class.Name, testMethod.Method.Name);
var testCase = new ExecutionErrorTestCase(DiagnosticMessageSink, TestMethodDisplay.ClassAndMethod, testMethod, message);
return ReportDiscoveredTestCase(testCase, includeSourceInformation, messageBus);
}
var factAttribute = factAttributes.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();
var discovererType = SerializationHelper.GetType(args[1], args[0]);
if (discovererType == null)
return true;
var discoverer = GetDiscoverer(discovererType);
if (discoverer == null)
return true;
foreach (var testCase in discoverer.Discover(discoveryOptions, testMethod, factAttribute))
if (!ReportDiscoveredTestCase(testCase, includeSourceInformation, messageBus))
return false;
return true;
}
示例7: Discover
public override IEnumerable<IXunitTestCase> Discover(
ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
{
string[] conditionMemberNames = factAttribute.GetConstructorArguments().FirstOrDefault() as string[];
IEnumerable<IXunitTestCase> testCases = base.Discover(discoveryOptions, testMethod, factAttribute);
return ConditionalTestDiscoverer.Discover(discoveryOptions, _diagnosticMessageSink, testMethod, testCases, conditionMemberNames);
}
示例8: Discover
public virtual IEnumerable<IXunitTestCase> Discover(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
{
var variations = testMethod.Method
.GetCustomAttributes(typeof(BenchmarkVariationAttribute))
.ToDictionary(
a => a.GetNamedArgument<string>(nameof(BenchmarkVariationAttribute.VariationName)),
a => a.GetNamedArgument<object[]>(nameof(BenchmarkVariationAttribute.Data)));
if (!variations.Any())
{
variations.Add("Default", new object[0]);
}
var tests = new List<IXunitTestCase>();
foreach (var variation in variations)
{
tests.Add(new BenchmarkTestCase(
factAttribute.GetNamedArgument<int>(nameof(BenchmarkAttribute.Iterations)),
factAttribute.GetNamedArgument<int>(nameof(BenchmarkAttribute.WarmupIterations)),
variation.Key,
_diagnosticMessageSink,
testMethod,
variation.Value));
}
return tests;
}
示例9: RunAll
/// <summary>
/// Starts the process of running all the tests in the assembly.
/// </summary>
/// <param name="executor">The executor.</param>
/// <param name="executionMessageSink">The message sink to report results back to.</param>
/// <param name="discoveryOptions">The options to be used during test discovery.</param>
/// <param name="executionOptions">The options to be used during test execution.</param>
public static void RunAll(this ITestFrameworkExecutor executor,
IMessageSinkWithTypes executionMessageSink,
ITestFrameworkDiscoveryOptions discoveryOptions,
ITestFrameworkExecutionOptions executionOptions)
{
executor.RunAll(MessageSinkAdapter.Wrap(executionMessageSink), discoveryOptions, executionOptions);
}
示例10: Discover
public override IEnumerable<IXunitTestCase> Discover(
ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
{
MethodInfo testMethodInfo = testMethod.Method.ToRuntimeMethod();
string conditionMemberName = factAttribute.GetConstructorArguments().FirstOrDefault() as string;
MethodInfo conditionMethodInfo;
if (conditionMemberName == null ||
(conditionMethodInfo = LookupConditionalMethod(testMethodInfo.DeclaringType, conditionMemberName)) == null)
{
return new[] {
new ExecutionErrorTestCase(
_diagnosticMessageSink,
discoveryOptions.MethodDisplayOrDefault(),
testMethod,
GetFailedLookupString(conditionMemberName))
};
}
IEnumerable<IXunitTestCase> testCases = base.Discover(discoveryOptions, testMethod, factAttribute);
if ((bool)conditionMethodInfo.Invoke(null, null))
{
return testCases;
}
else
{
string skippedReason = "\"" + conditionMemberName + "\" returned false.";
return testCases.Select(tc => new SkippedTestCase(tc, skippedReason));
}
}
示例11: FindTestsForMethod
/// <summary>
/// Finds the tests on a test method.
/// </summary>
/// <param name="testMethod">The test method.</param>
/// <param name="includeSourceInformation">Set to <c>true</c> to indicate that source information should be included.</param>
/// <param name="messageBus">The message bus to report discovery messages to.</param>
/// <param name="discoveryOptions">The options used by the test framework during discovery.</param>
/// <returns>Return <c>true</c> to continue test discovery, <c>false</c>, otherwise.</returns>
protected virtual 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();
var discovererType = SerializationHelper.GetType(args[1], args[0]);
if (discovererType == null)
return true;
var discoverer = GetDiscoverer(discovererType);
if (discoverer == null)
return true;
foreach (var testCase in discoverer.Discover(discoveryOptions, testMethod, factAttribute))
if (!ReportDiscoveredTestCase(testCase, includeSourceInformation, messageBus))
return false;
return true;
}
示例12: TestAssemblyDiscoveryStarting
/// <summary>
/// Initializes a new instance of the <see cref="TestAssemblyDiscoveryStarting"/> class.
/// </summary>
/// <param name="assembly">Information about the assembly that is being discovered</param>
/// <param name="discoveryOptions">The discovery options</param>
/// <param name="executionOptions">The execution options</param>
public TestAssemblyDiscoveryStarting(XunitProjectAssembly assembly,
ITestFrameworkDiscoveryOptions discoveryOptions,
ITestFrameworkExecutionOptions executionOptions)
{
Assembly = assembly;
DiscoveryOptions = discoveryOptions;
ExecutionOptions = executionOptions;
}
示例13: Discover
public IEnumerable<IXunitTestCase> Discover(
ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
{
Guard.AgainstNullArgument("discoveryOptions", discoveryOptions);
yield return new ScenarioOutline(
this.diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod);
}
示例14: SkipMethod
protected override bool SkipMethod(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
{
var classOfMethod = Type.GetType(testMethod.TestClass.Class.Name, true, true);
//in mixed mode we do not want to run any api tests for plugins when running against a snapshot
//because the client is "hot"
var collectionType = TestAssemblyRunner.GetClusterForCollection(testMethod.TestClass?.TestCollection);
return TestClient.Configuration.RunIntegrationTests && RequiresPluginButRunningAgainstSnapshot(classOfMethod, collectionType);
}
示例15: CreateTestCase
protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) {
if (testMethod.Method.ReturnType.Name == "System.Void" &&
testMethod.Method.GetCustomAttributes(typeof(AsyncStateMachineAttribute)).Any()) {
return new ExecutionErrorTestCase(diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, "Async void methods are not supported.");
}
return new LegacyUITestCase(UITestCase.SyncContextType.WPF, diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod);
}