зеркало из https://github.com/microsoft/testfx.git
Fixing merge conflicts.
This commit is contained in:
Коммит
58b0d22988
|
@ -102,8 +102,11 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution
|
|||
var logger = (IMessageLogger)frameworkHandle;
|
||||
|
||||
// discover the tests
|
||||
(new UnitTestDiscoverer()).DiscoverTestsInSource(source, logger, discoverySink, runContext?.RunSettings);
|
||||
this.GetUnitTestDiscoverer().DiscoverTestsInSource(source, logger, discoverySink, runContext?.RunSettings);
|
||||
tests.AddRange(discoverySink.Tests);
|
||||
|
||||
//Clear discoverSinksTests so that it just stores test for one source at one point of time
|
||||
discoverySink.Tests.Clear();
|
||||
}
|
||||
|
||||
bool isDeploymentDone = PlatformServiceProvider.Instance.TestDeployment.Deploy(tests, runContext, frameworkHandle);
|
||||
|
@ -123,7 +126,7 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution
|
|||
/// <summary>
|
||||
/// Execute the parameter tests
|
||||
/// </summary>
|
||||
private void ExecuteTests(IEnumerable<TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle, bool isDeploymentDone)
|
||||
internal virtual void ExecuteTests(IEnumerable<TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle, bool isDeploymentDone)
|
||||
{
|
||||
var testsBySource = (from test in tests
|
||||
group test by test.Source into testGroup
|
||||
|
@ -277,6 +280,11 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution
|
|||
this.LogWarnings(testExecutionRecorder, warnings);
|
||||
}
|
||||
|
||||
internal virtual UnitTestDiscoverer GetUnitTestDiscoverer()
|
||||
{
|
||||
return new UnitTestDiscoverer();
|
||||
}
|
||||
|
||||
private void CacheSessionParameters(IRunContext runContext, ITestExecutionRecorder testExecutionRecorder)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(runContext?.RunSettings?.SettingsXml))
|
||||
|
|
|
@ -117,7 +117,7 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter
|
|||
/// <param name="logger"> The logger. </param>
|
||||
/// <param name="discoverySink"> The discovery Sink. </param>
|
||||
/// <param name="runSettings"> The run settings. </param>
|
||||
internal void DiscoverTestsInSource(
|
||||
internal virtual void DiscoverTestsInSource(
|
||||
string source,
|
||||
IMessageLogger logger,
|
||||
ITestCaseDiscoverySink discoverySink,
|
||||
|
|
|
@ -261,4 +261,18 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Discovery
|
|||
|
||||
public int MaxLineNumber { get; set; }
|
||||
}
|
||||
|
||||
internal class TestableUnitTestDiscoverer : UnitTestDiscoverer
|
||||
{
|
||||
internal override void DiscoverTestsInSource(string source,
|
||||
IMessageLogger logger,
|
||||
ITestCaseDiscoverySink discoverySink,
|
||||
IRunSettings runSettings)
|
||||
{
|
||||
var testCase1 = new TestCase("A", new System.Uri("executor://testExecutor"), source);
|
||||
var testCase2 = new TestCase("B", new System.Uri("executor://testExecutor"), source);
|
||||
discoverySink.SendTestCase(testCase1);
|
||||
discoverySink.SendTestCase(testCase2);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution
|
|||
|
||||
using Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution;
|
||||
using Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel;
|
||||
using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Discovery;
|
||||
using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.TestableImplementations;
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
|
||||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter;
|
||||
|
@ -352,6 +353,22 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution
|
|||
Assert.IsNotNull(DummyTestClass.TestContextProperties);
|
||||
}
|
||||
|
||||
[TestMethodV1]
|
||||
public void RunTestsForMultipleSourcesShouldRunEachTestJustOnce()
|
||||
{
|
||||
int testsCount = 0;
|
||||
var sources = new List<string> { Assembly.GetExecutingAssembly().Location, Assembly.GetExecutingAssembly().Location };
|
||||
TestableTestExecutionManager testableTestExecutionmanager = new TestableTestExecutionManager();
|
||||
|
||||
testableTestExecutionmanager.ExecuteTestsWrapper = (tests, runContext, frameworkHandle, isDeploymentDone) =>
|
||||
{
|
||||
testsCount += tests.Count();
|
||||
};
|
||||
|
||||
testableTestExecutionmanager.RunTests(sources, this.runContext, this.frameworkHandle, this.cancellationToken);
|
||||
Assert.AreEqual(testsCount, 4);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region private methods
|
||||
|
@ -568,5 +585,24 @@ namespace Microsoft.VisualStudio.TestPlatform.MSTestAdapter.UnitTests.Execution
|
|||
}
|
||||
}
|
||||
|
||||
internal class TestableTestExecutionManager : TestExecutionManager
|
||||
{
|
||||
internal override void ExecuteTests(IEnumerable<TestCase> tests, IRunContext runContext,
|
||||
IFrameworkHandle frameworkHandle, bool isDeploymentDone)
|
||||
{
|
||||
if (this.ExecuteTestsWrapper != null)
|
||||
{
|
||||
this.ExecuteTestsWrapper.Invoke(tests, runContext, frameworkHandle, isDeploymentDone);
|
||||
}
|
||||
}
|
||||
|
||||
internal override UnitTestDiscoverer GetUnitTestDiscoverer()
|
||||
{
|
||||
return new TestableUnitTestDiscoverer();
|
||||
}
|
||||
|
||||
internal Action<IEnumerable<TestCase>, IRunContext, IFrameworkHandle, bool> ExecuteTestsWrapper;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче