forked from microsoft/vstest
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
TestAdapter.cs
71 lines (64 loc) · 2.12 KB
/
TestAdapter.cs
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
namespace NonDll.TestAdapter;
[FileExtension(".js")]
[DefaultExecutorUri(Uri)]
[ExtensionUri(Uri)]
public class TestAdapter : ITestExecutor, ITestDiscoverer
{
public const string Uri = "executor://nondll.testadapter";
public void DiscoverTests(IEnumerable<string> sources, IDiscoveryContext discoveryContext,
IMessageLogger logger, ITestCaseDiscoverySink discoverySink)
{
var count = 1;
foreach (var source in sources)
{
TestCase testCase = new()
{
Source = source,
CodeFilePath = source,
DisplayName = $"Test{count++}",
ExecutorUri = new Uri(Uri),
};
discoverySink.SendTestCase(testCase);
}
}
public void Cancel()
{
}
public void RunTests(IEnumerable<TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle)
{
foreach (var test in tests)
{
TestResult testResult = new(test)
{
Outcome = TestOutcome.Passed,
};
frameworkHandle.RecordResult(testResult);
}
}
public void RunTests(IEnumerable<string> sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
{
var count = 1;
foreach (var source in sources)
{
TestCase testCase = new()
{
Source = source,
CodeFilePath = source,
DisplayName = $"Test{count++}",
ExecutorUri = new Uri(Uri),
};
TestResult testResult = new(testCase)
{
Outcome = TestOutcome.Passed,
};
frameworkHandle.RecordResult(testResult);
}
}
}