-
Notifications
You must be signed in to change notification settings - Fork 293
Expand file tree
/
Copy pathMSTestDiscoverer.cs
More file actions
72 lines (62 loc) · 3.08 KB
/
MSTestDiscoverer.cs
File metadata and controls
72 lines (62 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices;
using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
namespace Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter;
/// <summary>
/// Contains the discovery logic for this adapter.
/// </summary>
[DefaultExecutorUri(MSTestAdapter.PlatformServices.EngineConstants.ExecutorUriString)]
[FileExtension(".xap")]
[FileExtension(".appx")]
[FileExtension(".dll")]
[FileExtension(".exe")]
internal sealed class MSTestDiscoverer : ITestDiscoverer
{
private readonly ITestSourceHandler _testSourceHandler;
public MSTestDiscoverer()
: this(new TestSourceHandler())
{
}
internal /* for testing purposes */ MSTestDiscoverer(ITestSourceHandler testSourceHandler)
=> _testSourceHandler = testSourceHandler;
/// <summary>
/// Discovers the tests available from the provided source. Not supported for .xap source.
/// </summary>
/// <param name="sources">Collection of test containers.</param>
/// <param name="discoveryContext">Context in which discovery is being performed.</param>
/// <param name="logger">Logger used to log messages.</param>
/// <param name="discoverySink">Used to send testcases and discovery related events back to Discoverer manager.</param>
[System.Security.SecurityCritical]
[SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "Discovery context can be null.")]
public void DiscoverTests(IEnumerable<string> sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink)
=> DiscoverTests(sources, discoveryContext, logger, discoverySink, null, isMTP: false);
internal void DiscoverTests(IEnumerable<string> sources, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink, IConfiguration? configuration, bool isMTP)
{
#if NET6_0_OR_GREATER
ArgumentNullException.ThrowIfNull(sources);
ArgumentNullException.ThrowIfNull(logger);
ArgumentNullException.ThrowIfNull(discoverySink);
#else
if (sources is null)
{
throw new ArgumentNullException(nameof(sources));
}
if (logger is null)
{
throw new ArgumentNullException(nameof(logger));
}
if (discoverySink is null)
{
throw new ArgumentNullException(nameof(discoverySink));
}
#endif
if (MSTestDiscovererHelpers.InitializeDiscovery(sources, discoveryContext, logger, configuration, _testSourceHandler))
{
new UnitTestDiscoverer(_testSourceHandler).DiscoverTests(sources, logger, discoverySink, discoveryContext, isMTP);
}
}
}