提交 42c06aab 编写于 作者: S Sam Harwell

Account for XUnit serialization in passed tests

上级 7fab9045
......@@ -9,38 +9,34 @@ namespace Roslyn.Test.Utilities
public class WpfFactDiscoverer : FactDiscoverer
{
private readonly IMessageSink _diagnosticMessageSink;
private readonly IDictionary<string, TestInfo> _passedTests;
public WpfFactDiscoverer(IMessageSink diagnosticMessageSink) : base(diagnosticMessageSink)
{
_diagnosticMessageSink = diagnosticMessageSink;
_passedTests = TestInfo.GetPassedTestsInfo();
}
protected override IXunitTestCase CreateTestCase(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo factAttribute)
=> new WpfTestCase(_diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, _passedTests);
=> new WpfTestCase(_diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod);
}
public class WpfTheoryDiscoverer : TheoryDiscoverer
{
private readonly IMessageSink _diagnosticMessageSink;
private readonly IDictionary<string, TestInfo> _passedTests;
public WpfTheoryDiscoverer(IMessageSink diagnosticMessageSink) : base(diagnosticMessageSink)
{
_diagnosticMessageSink = diagnosticMessageSink;
_passedTests = TestInfo.GetPassedTestsInfo();
}
protected override IEnumerable<IXunitTestCase> CreateTestCasesForDataRow(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute, object[] dataRow)
{
var testCase = new WpfTestCase(_diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, _passedTests, dataRow);
var testCase = new WpfTestCase(_diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, dataRow);
return new[] { testCase };
}
protected override IEnumerable<IXunitTestCase> CreateTestCasesForTheory(ITestFrameworkDiscoveryOptions discoveryOptions, ITestMethod testMethod, IAttributeInfo theoryAttribute)
{
var testCase = new WpfTheoryTestCase(_diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod, _passedTests);
var testCase = new WpfTheoryTestCase(_diagnosticMessageSink, discoveryOptions.MethodDisplayOrDefault(), discoveryOptions.MethodDisplayOptionsOrDefault(), testMethod);
return new[] { testCase };
}
}
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Threading;
using System.Threading.Tasks;
......@@ -12,24 +11,20 @@ namespace Roslyn.Test.Utilities
{
public sealed class WpfTestCase : XunitTestCase
{
private readonly IDictionary<string, TestInfo> _passedTests;
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes")]
public WpfTestCase()
{
_passedTests = new Dictionary<string, TestInfo>();
}
public WpfTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, IDictionary<string, TestInfo> passedTests, object[] testMethodArguments = null)
public WpfTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, object[] testMethodArguments = null)
: base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod, testMethodArguments)
{
_passedTests = passedTests;
}
public override Task<RunSummary> RunAsync(IMessageSink diagnosticMessageSink, IMessageBus messageBus, object[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource)
{
var runner = new WpfTestCaseRunner(WpfTestSharedData.Instance, this, DisplayName, SkipReason, constructorArguments, TestMethodArguments, messageBus, aggregator, _passedTests, cancellationTokenSource);
var runner = new WpfTestCaseRunner(WpfTestSharedData.Instance, this, DisplayName, SkipReason, constructorArguments, TestMethodArguments, messageBus, aggregator, cancellationTokenSource);
return runner.RunAsync();
}
}
......
......@@ -12,7 +12,6 @@ namespace Roslyn.Test.Utilities
public sealed class WpfTestCaseRunner : XunitTestCaseRunner
{
public WpfTestSharedData SharedData { get; }
public readonly IDictionary<string, TestInfo> _passedTests;
public WpfTestCaseRunner(
WpfTestSharedData sharedData,
......@@ -23,17 +22,15 @@ public sealed class WpfTestCaseRunner : XunitTestCaseRunner
object[] testMethodArguments,
IMessageBus messageBus,
ExceptionAggregator aggregator,
IDictionary<string, TestInfo> passedTests,
CancellationTokenSource cancellationTokenSource)
: base(testCase, displayName, skipReason, constructorArguments, testMethodArguments, messageBus, aggregator, cancellationTokenSource)
{
SharedData = sharedData;
_passedTests = passedTests;
}
protected override XunitTestRunner CreateTestRunner(ITest test, IMessageBus messageBus, Type testClass, object[] constructorArguments, MethodInfo testMethod, object[] testMethodArguments, string skipReason, IReadOnlyList<BeforeAfterTestAttribute> beforeAfterAttributes, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource)
{
var runner = new WpfTestRunner(SharedData, test, messageBus, testClass, constructorArguments, testMethod, testMethodArguments, skipReason, beforeAfterAttributes, aggregator, _passedTests, cancellationTokenSource);
var runner = new WpfTestRunner(SharedData, test, messageBus, testClass, constructorArguments, testMethod, testMethodArguments, skipReason, beforeAfterAttributes, aggregator, cancellationTokenSource);
return runner;
}
}
......
......@@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Reflection;
using System.Threading;
......@@ -25,10 +26,15 @@ namespace Roslyn.Test.Utilities
/// </summary>
public sealed class WpfTestRunner : XunitTestRunner
{
private static readonly ImmutableDictionary<string, TestInfo> _passedTests;
private static string s_wpfFactRequirementReason;
public WpfTestSharedData SharedData { get; }
public readonly IDictionary<string, TestInfo> _passedTests;
static WpfTestRunner()
{
_passedTests = TestInfo.GetPassedTestsInfo();
}
public WpfTestRunner(
WpfTestSharedData sharedData,
......@@ -41,12 +47,10 @@ public sealed class WpfTestRunner : XunitTestRunner
string skipReason,
IReadOnlyList<BeforeAfterTestAttribute> beforeAfterAttributes,
ExceptionAggregator aggregator,
IDictionary<string, TestInfo> passedTests,
CancellationTokenSource cancellationTokenSource)
: base(test, messageBus, testClass, constructorArguments, testMethod, testMethodArguments, skipReason, beforeAfterAttributes, aggregator, cancellationTokenSource)
{
SharedData = sharedData;
_passedTests = passedTests;
}
protected override Task<decimal> InvokeTestMethodAsync(ExceptionAggregator aggregator)
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Threading;
using System.Threading.Tasks;
......@@ -12,24 +11,20 @@ namespace Roslyn.Test.Utilities
{
public class WpfTheoryTestCase : XunitTheoryTestCase
{
public readonly IDictionary<string, TestInfo> _passedTests;
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes")]
public WpfTheoryTestCase()
{
_passedTests = new Dictionary<string, TestInfo>();
}
public WpfTheoryTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod, IDictionary<string, TestInfo> passedTests)
public WpfTheoryTestCase(IMessageSink diagnosticMessageSink, TestMethodDisplay defaultMethodDisplay, TestMethodDisplayOptions defaultMethodDisplayOptions, ITestMethod testMethod)
: base(diagnosticMessageSink, defaultMethodDisplay, defaultMethodDisplayOptions, testMethod)
{
_passedTests = passedTests;
}
public override Task<RunSummary> RunAsync(IMessageSink diagnosticMessageSink, IMessageBus messageBus, object[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource)
{
var runner = new WpfTheoryTestCaseRunner(WpfTestSharedData.Instance, this, DisplayName, SkipReason, constructorArguments, diagnosticMessageSink, messageBus, aggregator, _passedTests, cancellationTokenSource);
var runner = new WpfTheoryTestCaseRunner(WpfTestSharedData.Instance, this, DisplayName, SkipReason, constructorArguments, diagnosticMessageSink, messageBus, aggregator, cancellationTokenSource);
return runner.RunAsync();
}
}
......
......@@ -12,7 +12,6 @@ namespace Roslyn.Test.Utilities
public class WpfTheoryTestCaseRunner : XunitTheoryTestCaseRunner
{
public WpfTestSharedData SharedData { get; }
public readonly IDictionary<string, TestInfo> _passedTests;
public WpfTheoryTestCaseRunner(
WpfTestSharedData sharedData,
......@@ -23,17 +22,15 @@ public class WpfTheoryTestCaseRunner : XunitTheoryTestCaseRunner
IMessageSink diagnosticMessageSink,
IMessageBus messageBus,
ExceptionAggregator aggregator,
IDictionary<string, TestInfo> passedTests,
CancellationTokenSource cancellationTokenSource)
: base(testCase, displayName, skipReason, constructorArguments, diagnosticMessageSink, messageBus, aggregator, cancellationTokenSource)
{
SharedData = sharedData;
_passedTests = passedTests;
}
protected override XunitTestRunner CreateTestRunner(ITest test, IMessageBus messageBus, Type testClass, object[] constructorArguments, MethodInfo testMethod, object[] testMethodArguments, string skipReason, IReadOnlyList<BeforeAfterTestAttribute> beforeAfterAttributes, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource)
{
var runner = new WpfTestRunner(SharedData, test, messageBus, testClass, constructorArguments, testMethod, testMethodArguments, skipReason, beforeAfterAttributes, aggregator, _passedTests, cancellationTokenSource);
var runner = new WpfTestRunner(SharedData, test, messageBus, testClass, constructorArguments, testMethod, testMethodArguments, skipReason, beforeAfterAttributes, aggregator, cancellationTokenSource);
return runner;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册