protected override IEnumerable <IXunitTestCase> CreateTestCasesForDataRow( ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute, object[] dataRow) { var skipReason = testMethod.EvaluateSkipConditions(); if (skipReason == null && dataRow?.Length > 0) { var obj = dataRow[0]; if (obj != null) { var type = obj.GetType(); var property = type.GetProperty("Skip"); if (property != null && property.PropertyType.Equals(typeof(string))) { skipReason = property.GetValue(obj) as string; } } } return(skipReason != null ? base.CreateTestCasesForSkippedDataRow(discoveryOptions, testMethod, theoryAttribute, dataRow, skipReason) : base.CreateTestCasesForDataRow(discoveryOptions, testMethod, theoryAttribute, dataRow)); }
protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) { var skipReason = testMethod.EvaluateSkipConditions(); return(skipReason != null ? new SkippedTestCase(skipReason, _diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), TestMethodDisplayOptions.None, testMethod) : base.CreateTestCase(discoveryOptions, testMethod, factAttribute)); }
protected override IEnumerable <IXunitTestCase> CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute) { var skipReason = testMethod.EvaluateSkipConditions(); return(skipReason != null ? new[] { new SkippedTestCase(skipReason, DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod) } : base.CreateTestCasesForTheory(discoveryOptions, testMethod, theoryAttribute)); }
protected override IEnumerable <IXunitTestCase> CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute, object[] dataRow) { var skipReason = testMethod.EvaluateSkipConditions(); return(skipReason != null ? CreateTestCasesForSkippedDataRow(discoveryOptions, testMethod, theoryAttribute, dataRow, skipReason) : base.CreateTestCasesForDataRow(discoveryOptions, testMethod, theoryAttribute, dataRow)); }
protected override IXunitTestCase CreateTestCase( ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) { if (!IsStressTestBase(testMethod.TestClass.Class)) { return(new ExecutionErrorTestCase( _diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod, $"Could not resolve stress test because its parent class did not inherit from {testMethod.TestClass.Class.Name}.")); } var skipReason = testMethod.EvaluateSkipConditions(); if (skipReason != null) { return(new SkippedTestCase( skipReason, _diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod)); } var testApplicationName = factAttribute.GetNamedArgument <string>(nameof(StressAttribute.TestApplicationName)); var iterations = StressConfig.Instance.RunIterations ? factAttribute.GetNamedArgument <long>(nameof(StressAttribute.Iterations)) : 1; var threads = factAttribute.GetNamedArgument <int>(nameof(StressAttribute.Clients)); var serverType = factAttribute.GetNamedArgument <ServerType>(nameof(StressAttribute.Server)); var warmupMethod = ResolveWarmupMethod(testMethod, factAttribute); return(new StressTestCase( testApplicationName, iterations, threads, serverType, warmupMethod, _diagnosticMessageSink, testMethod)); }
public virtual IEnumerable <IXunitTestCase> Discover( ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) { try { var skipReason = testMethod.EvaluateSkipConditions(); if (skipReason != null) { return(new[] { new SkippedTestCase( skipReason, _diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), testMethod), }); } var variations = testMethod.Method .GetCustomAttributes(typeof(BenchmarkVariationAttribute)) .Select(a => new { Name = a.GetNamedArgument <string>(nameof(BenchmarkVariationAttribute.VariationName)), TestMethodArguments = a.GetNamedArgument <object[]>(nameof(BenchmarkVariationAttribute.Data)), Framework = a.GetNamedArgument <string>(nameof(BenchmarkVariationAttribute.Framework)) }) .ToList(); if (!variations.Any()) { variations.Add(new { Name = "Default", TestMethodArguments = new object[0], Framework = (string)null }); } var tests = new List <IXunitTestCase>(); foreach (var variation in variations) { if (BenchmarkConfig.Instance.RunIterations) { tests.Add(new BenchmarkTestCase( factAttribute.GetNamedArgument <int>(nameof(BenchmarkAttribute.Iterations)), factAttribute.GetNamedArgument <int>(nameof(BenchmarkAttribute.WarmupIterations)), variation.Framework, variation.Name, _diagnosticMessageSink, testMethod, variation.TestMethodArguments)); } else { tests.Add(new NonCollectingBenchmarkTestCase( variation.Name, _diagnosticMessageSink, testMethod, variation.TestMethodArguments)); } } return(tests); } catch (Exception e) { Console.WriteLine(e); Console.WriteLine(e.StackTrace); throw; } }
protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute) { return(new SkippableTestCase(testMethod.EvaluateSkipConditions(), DiagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod)); }