/// <summary> /// Initializes a new instance of the <see cref="DisplayNameFormatter"/> class. /// </summary> /// <param name="display">The <see cref="TestMethodDisplay"/> used by the formatter.</param> /// <param name="displayOptions">The <see cref="TestMethodDisplayOptions"/> used by the formatter.</param> public DisplayNameFormatter(TestMethodDisplay display, TestMethodDisplayOptions displayOptions) { rule = new CharacterRule(); if ((displayOptions & UseEscapeSequences) == UseEscapeSequences) { rule = new ReplaceEscapeSequenceRule() { Next = rule }; } if ((displayOptions & ReplaceUnderscoreWithSpace) == ReplaceUnderscoreWithSpace) { rule = new ReplaceUnderscoreRule() { Next = rule }; } if ((displayOptions & UseOperatorMonikers) == UseOperatorMonikers) { rule = new ReplaceOperatorMonikerRule() { Next = rule }; } if (display == ClassAndMethod) { if ((displayOptions & ReplacePeriodWithComma) == ReplacePeriodWithComma) { rule = new ReplacePeriodRule() { Next = rule }; } else { rule = new KeepPeriodRule() { Next = rule }; } } }
/// <summary> /// Initializes a new instance of the <see cref="XunitTestCase"/> class. /// </summary> /// <param name="diagnosticMessageSink">The message sink used to send diagnostic messages</param> /// <param name="defaultMethodDisplay">Default method display to use (when not customized).</param> /// <param name="defaultMethodDisplayOptions">Default method display options to use (when not customized).</param> /// <param name="testMethod">The test method this test case belongs to.</param> /// <param name="testMethodArguments">The arguments for the test method.</param> public XunitTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, object[] testMethodArguments = null) : base(defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments) { this.diagnosticMessageSink = diagnosticMessageSink; }
/// <summary> /// Initializes a new instance of the <see cref="ExecutionErrorTestCase"/> class. /// </summary> /// <param name="diagnosticMessageSink">The message sink used to send diagnostic messages</param> /// <param name="defaultMethodDisplay">Default method display to use (when not customized).</param> /// <param name="defaultMethodDisplayOptions">Default method display options to use (when not customized).</param> /// <param name="testMethod">The test method.</param> /// <param name="errorMessage">The error message to report for the test.</param> public ExecutionErrorTestCase( IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, string errorMessage) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod) { ErrorMessage = errorMessage; }
public CulturedXunitTestCase( IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, string culture) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod) { Initialize(culture); }
/// <summary> /// Initializes a new instance of the <see cref="XunitSkippedDataRowTestCase"/> class. /// </summary> /// <param name="diagnosticMessageSink">The message sink used to send diagnostic messages</param> /// <param name="defaultMethodDisplay">Default method display to use (when not customized).</param> /// <param name="defaultMethodDisplayOptions">Default method display options to use (when not customized).</param> /// <param name="testMethod">The test method this test case belongs to.</param> /// <param name="skipReason">The reason that this test case will be skipped</param> /// <param name="testMethodArguments">The arguments for the test method.</param> public XunitSkippedDataRowTestCase( IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, string skipReason, object[] testMethodArguments = null) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments) { this.skipReason = skipReason; }
/// <summary> /// Initializes a new instance of the <see cref="TestMethodTestCase"/> class. /// </summary> /// <param name="defaultMethodDisplay">Default method display to use (when not customized).</param> /// <param name="defaultMethodDisplayOptions">Default method display options to use (when not customized).</param> /// <param name="testMethod">The test method this test case belongs to.</param> /// <param name="testMethodArguments">The arguments for the test method.</param> protected TestMethodTestCase( TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, object[] testMethodArguments = null) { DefaultMethodDisplay = defaultMethodDisplay; DefaultMethodDisplayOptions = defaultMethodDisplayOptions; formatter = new DisplayNameFormatter(defaultMethodDisplay, defaultMethodDisplayOptions); TestMethod = testMethod; TestMethodArguments = testMethodArguments; }
public GeneratorContactCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, int dataNumber) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments: null) { mDataNumber = dataNumber; }
public SkippedTheoryTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod) { }
public ForegroundTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, object[] testMethodArguments = null) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments) { }
public SkipTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, string skipReason) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod) { SkipReason = skipReason; }
public WpfTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, object[] testMethodArguments = null) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments) { SharedData = WpfTestSharedData.Instance; }
//[Obsolete] //public RetryTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay testMethodDisplay, ITestMethod testMethod, int maxRetries) // : base(diagnosticMessageSink, testMethodDisplay, testMethod, testMethodArguments: null) //{ // this.maxRetries = maxRetries; //} public RetryTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, int maxRetries, object[] testMethodArguments = null) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments) { this.maxRetries = maxRetries; }
public ScenarioFactTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, object[] testMethodArguments, string factName, SourceInformation sourceInformation, int theoryTestCaseLimit, ScenarioTestExecutionPolicy scenarioTestExecutionPolicy, bool runInIsolation) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments) { _factName = factName; _theoryTestCaseLimit = theoryTestCaseLimit; _scenarioTestExecutionPolicy = scenarioTestExecutionPolicy; _runInIsolation = runInIsolation; SourceInformation = sourceInformation; }
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. public MefFactTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions testMethodDisplayOptions, ITestMethod testMethod, IAttributeInfo factAttributeInfo) : base(diagnosticMessageSink, defaultMethodDisplay, testMethodDisplayOptions, testMethod) { var factAttribute = MefFactAttribute.Instantiate(factAttributeInfo); this.SkipReason = factAttribute.Skip; this.parts = factAttribute.Parts; this.assemblies = factAttribute.Assemblies; this.compositionVersions = factAttribute.CompositionVersions; this.noCompatGoal = factAttribute.NoCompatGoal; this.invalidConfiguration = factAttribute.InvalidConfiguration; if (this.Traits.ContainsKey(Tests.Traits.SkipOnMono) && TestUtilities.IsOnMono) { this.SkipReason = this.SkipReason ?? "Test marked as skipped on Mono runtime due to unsupported feature: " + string.Join(", ", this.Traits[Tests.Traits.SkipOnMono]); } if (this.Traits.ContainsKey(Tests.Traits.SkipOnCoreCLR) && TestUtilities.IsOnCoreCLR) { this.SkipReason = this.SkipReason ?? "Test marked as skipped on CoreCLR runtime due to unsupported feature: " + string.Join(", ", this.Traits[Tests.Traits.SkipOnCoreCLR]); } }
public SkippableTestCase(string skipReason, IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, object[] testMethodArguments = null) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments) { _skipReason = skipReason; }
public SkippedTestCase(string skipReason, IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, null) { _skipReason = skipReason; }
public ObservationTestCase(TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod) : base(defaultMethodDisplay, defaultMethodDisplayOptions, testMethod) { }
public UITheoryTestCase(UITestCase.SyncContextType synchronizationContextType, IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod) { this.SynchronizationContextType = synchronizationContextType; }
public SkippableTheoryTestCase(string[] skippingExceptionNames, IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod) { this.SkippingExceptionNames = skippingExceptionNames ?? throw new ArgumentNullException(nameof(skippingExceptionNames)); }
public TestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod) : this(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, null) { }
internal RetryTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay testMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, int maxRetries) : base(diagnosticMessageSink, testMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments: null) { _maxRetries = maxRetries; }
public ErrorIntegrationTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, string errorMessage) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod) => ErrorMessage = errorMessage ?? throw new ArgumentNullException(nameof(errorMessage));
public BenchmarkTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, IAttributeInfo attr, object[] testMethodArguments = null) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments) { DiscoverArguments = testMethodArguments == null; }
public MigrationsTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, DatabaseProvider provider, ProgrammingLanguage language) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod) { _provider = provider; _language = language; DisplayName = string.Format( "{0} - DatabaseProvider: {1}, ProgrammingLanguage: {2}", DisplayName, _provider, _language); }
public RetryTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, int maxRetries, int timeSleep) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments: null) { mMaxRetries = maxRetries; mTimeSleep = timeSleep; }
public GeneratorDoubleCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, int dataNumber, double maxValue, double minValue) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments: null) { mDataNumber = dataNumber; mMaxValue = maxValue; mMinValue = minValue; }
public ExecutionErrorScenarioTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay methodDisplayOrDefault, TestMethodDisplayOptions methodDisplayOptionsOrDefault, ITestMethod testMethod, IScenarioIdentifier scenarioIdentifier, string errorMessage) : base(diagnosticMessageSink, methodDisplayOrDefault, methodDisplayOptionsOrDefault, testMethod, errorMessage) { _scenarioIdentifier = scenarioIdentifier ?? throw new ArgumentNullException(nameof(scenarioIdentifier)); }
public TestCaseSkippedDueToSerializerSupport(string skipReason, IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, object[] testMethodArguments = null) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments) { SkipReason = skipReason; }
public RetryTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay testMethodDisplay, TestMethodDisplayOptions testMethodDisplayOptions, ITestMethod testMethod, int maxRetries) : base(diagnosticMessageSink, testMethodDisplay, testMethodDisplayOptions, testMethod, testMethodArguments: null) { this.maxRetries = maxRetries; }
public ScenarioOutlineTestCase( IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod) { }
public WpfTheoryTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod) { SharedData = WpfTestSharedData.Instance; }
/// <summary> /// Sets the flags that determine the default display options for test methods. /// </summary> public static void SetMethodDisplayOptions(this ITestFrameworkDiscoveryOptions discoveryOptions, TestMethodDisplayOptions? value) { discoveryOptions.SetValue(TestOptionsNames.Discovery.MethodDisplayOptions, value.HasValue ? value.GetValueOrDefault().ToString() : null); }
public GeneratorPasswordCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, int dataNumber, int maxSize, int minSize) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments: null) { mDataNumber = dataNumber; mMaxSize = maxSize; mMinSize = minSize; }
// This helper method evaluates the given condition member names for a given set of test cases. // If any condition member evaluates to 'false', the test cases are marked to be skipped. // The skip reason is the collection of all the condition members that evalated to 'false'. internal static IEnumerable <IXunitTestCase> Discover( ITestFrameworkDiscoveryOptions discoveryOptions, IMessageSink diagnosticMessageSink, ITestMethod testMethod, IEnumerable <IXunitTestCase> testCases, object[] conditionArguments) { Type calleeType = null; string[] conditionMemberNames = null; if (CheckInputToSkipExecution(conditionArguments, ref calleeType, ref conditionMemberNames, testMethod)) { return(testCases); } MethodInfo testMethodInfo = testMethod.Method.ToRuntimeMethod(); Type testMethodDeclaringType = testMethodInfo.DeclaringType; List <string> falseConditions = new List <string>(conditionMemberNames.Count()); TestMethodDisplay defaultMethodDisplay = discoveryOptions.MethodDisplayOrDefault(); TestMethodDisplayOptions defaultMethodDisplayOptions = discoveryOptions.MethodDisplayOptionsOrDefault(); foreach (string entry in conditionMemberNames) { string conditionMemberName = entry; // Null condition member names are silently tolerated if (string.IsNullOrWhiteSpace(conditionMemberName)) { continue; } Type declaringType; if (calleeType != null) { declaringType = calleeType; } else { declaringType = testMethodDeclaringType; string[] symbols = conditionMemberName.Split('.'); if (symbols.Length == 2) { conditionMemberName = symbols[1]; ITypeInfo type = testMethod.TestClass.Class.Assembly.GetTypes(false).Where(t => t.Name.Contains(symbols[0])).FirstOrDefault(); if (type != null) { declaringType = type.ToRuntimeType(); } } } MethodInfo conditionMethodInfo; if ((conditionMethodInfo = LookupConditionalMethod(declaringType, conditionMemberName)) == null) { return(new[] { new ExecutionErrorTestCase( diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, GetFailedLookupString(conditionMemberName, declaringType)) }); } // In the case of multiple conditions, collect the results of all // of them to produce a summary skip reason. try { if (!(bool)conditionMethodInfo.Invoke(null, null)) { falseConditions.Add(conditionMemberName); } } catch (Exception exc) { falseConditions.Add($"{conditionMemberName} ({exc.GetType().Name})"); } } // Compose a summary of all conditions that returned false. if (falseConditions.Count > 0) { string skippedReason = string.Format("Condition(s) not met: \"{0}\"", string.Join("\", \"", falseConditions)); return(testCases.Select(tc => new SkippedTestCase(tc, skippedReason))); } // No conditions returned false (including the absence of any conditions). return(testCases); }
public RetryTheoryTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay testMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, int maxRetries) : base(diagnosticMessageSink, testMethodDisplay, defaultMethodDisplayOptions, testMethod) { this.maxRetries = maxRetries; }
/// <summary> /// Initializes a new instance of the <see cref="XunitTheoryTestCase"/> class. /// </summary> /// <param name="diagnosticMessageSink">The message sink used to send diagnostic messages</param> /// <param name="defaultMethodDisplay">Default method display to use (when not customized).</param> /// <param name="defaultMethodDisplayOptions">Default method display options to use (when not customized).</param> /// <param name="testMethod">The method under test.</param> public XunitTheoryTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod) { }
public NamedSkippedDataRowTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, string skipReason, object[] testMethodArguments = null) : base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, skipReason, testMethodArguments) { }