From 6a195a3d3e2020f767ff218406c2aead95228678 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Jare=C5=A1?= Date: Fri, 20 Jan 2023 09:58:07 +0100 Subject: [PATCH] Remove chutzpah (#4249) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Amaury Levé --- scripts/build/TestPlatform.Dependencies.props | 1 - .../DifferentTestFrameworkSimpleTests.cs | 11 ++- ...rosoft.TestPlatform.AcceptanceTests.csproj | 1 - .../DifferentTestFrameworkSimpleTests.cs | 17 ++--- .../IntegrationTestBase.cs | 13 ++-- .../NonDll.TestAdapter.csproj | 14 ++++ .../NonDll.TestAdapter/TestAdapter.cs | 71 +++++++++++++++++++ test/TestAssets/TestAssets.sln | 6 ++ 8 files changed, 113 insertions(+), 21 deletions(-) create mode 100644 test/TestAssets/NonDll.TestAdapter/NonDll.TestAdapter.csproj create mode 100644 test/TestAssets/NonDll.TestAdapter/TestAdapter.cs diff --git a/scripts/build/TestPlatform.Dependencies.props b/scripts/build/TestPlatform.Dependencies.props index c6a29db2c7..a675de6daa 100644 --- a/scripts/build/TestPlatform.Dependencies.props +++ b/scripts/build/TestPlatform.Dependencies.props @@ -27,7 +27,6 @@ 3.11.0 3.8.0 - 4.4.13 6.7.0 + + + + netstandard2.0 + latest + + + + + + \ No newline at end of file diff --git a/test/TestAssets/NonDll.TestAdapter/TestAdapter.cs b/test/TestAssets/NonDll.TestAdapter/TestAdapter.cs new file mode 100644 index 0000000000..b1811d25e4 --- /dev/null +++ b/test/TestAssets/NonDll.TestAdapter/TestAdapter.cs @@ -0,0 +1,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 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 tests, IRunContext runContext, IFrameworkHandle frameworkHandle) + { + foreach (var test in tests) + { + TestResult testResult = new(test) + { + Outcome = TestOutcome.Passed, + }; + frameworkHandle.RecordResult(testResult); + } + } + + public void RunTests(IEnumerable 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); + } + } +} diff --git a/test/TestAssets/TestAssets.sln b/test/TestAssets/TestAssets.sln index 37527a5c4a..3db3824c34 100644 --- a/test/TestAssets/TestAssets.sln +++ b/test/TestAssets/TestAssets.sln @@ -130,6 +130,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SerializeTestRunTestProject EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MultiHostTestExecutionProject", "MultiHostTestExecutionProject\MultiHostTestExecutionProject.csproj", "{CE6673DA-B50F-46DF-99A3-8A7C54DE9B61}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NonDll.TestAdapter", "NonDll.TestAdapter\NonDll.TestAdapter.csproj", "{429552A4-4C18-4355-94C5-80DC88C48405}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -372,6 +374,10 @@ Global {CE6673DA-B50F-46DF-99A3-8A7C54DE9B61}.Debug|Any CPU.Build.0 = Debug|Any CPU {CE6673DA-B50F-46DF-99A3-8A7C54DE9B61}.Release|Any CPU.ActiveCfg = Release|Any CPU {CE6673DA-B50F-46DF-99A3-8A7C54DE9B61}.Release|Any CPU.Build.0 = Release|Any CPU + {429552A4-4C18-4355-94C5-80DC88C48405}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {429552A4-4C18-4355-94C5-80DC88C48405}.Debug|Any CPU.Build.0 = Debug|Any CPU + {429552A4-4C18-4355-94C5-80DC88C48405}.Release|Any CPU.ActiveCfg = Release|Any CPU + {429552A4-4C18-4355-94C5-80DC88C48405}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE