Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ Copyright (c) .NET Foundation. All rights reserved.
</PropertyGroup>
<Import Condition="Exists('$(VSTestTargets)')" Project="$(VSTestTargets)" />
<Target Name="_MTPBuild">
<CallTarget Targets="Build" />
<CallTarget Targets="Build" Condition="'$(IsTestingPlatformApplication)'=='true'" />
</Target>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace ClassLibrary
{
public class Class1
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using Microsoft.Testing.Platform.Builder;
using Microsoft.Testing.Platform.Capabilities.TestFramework;
using Microsoft.Testing.Platform.Extensions.Messages;
using Microsoft.Testing.Platform.Extensions.TestFramework;

var testApplicationBuilder = await TestApplication.CreateBuilderAsync(args);

testApplicationBuilder.RegisterTestFramework(_ => new TestFrameworkCapabilities(), (_, __) => new DummyTestAdapter());

using var testApplication = await testApplicationBuilder.BuildAsync();
return await testApplication.RunAsync();

public class DummyTestAdapter : ITestFramework, IDataProducer
{
public string Uid => nameof(DummyTestAdapter);

public string Version => "2.0.0";

public string DisplayName => nameof(DummyTestAdapter);

public string Description => nameof(DummyTestAdapter);

public Task<bool> IsEnabledAsync() => Task.FromResult(true);

public Type[] DataTypesProduced => new[] {
typeof(TestNodeUpdateMessage)
};

public Task<CreateTestSessionResult> CreateTestSessionAsync(CreateTestSessionContext context)
=> Task.FromResult(new CreateTestSessionResult() { IsSuccess = true });

public Task<CloseTestSessionResult> CloseTestSessionAsync(CloseTestSessionContext context)
=> Task.FromResult(new CloseTestSessionResult() { IsSuccess = true });

public async Task ExecuteRequestAsync(ExecuteRequestContext context)
{
await context.MessageBus.PublishAsync(this, new TestNodeUpdateMessage(context.Request.Session.SessionUid, new TestNode()
{
Uid = "Test0",
DisplayName = "Test0",
Properties = new PropertyBag(new PassedTestNodeStateProperty("OK")),
}));

context.Complete();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), testAsset.props))\testAsset.props" />

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>$(CurrentTargetFramework)</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\ClassLibrary\ClassLibrary.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Testing.Platform" Version="$(MicrosoftTestingPlatformVersion)" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.14.35712.36 main
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestProject", "TestProject\TestProject.csproj", "{4868FD55-C56D-445C-9F83-A063302EC78F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClassLibrary", "ClassLibrary\ClassLibrary.csproj", "{729A12AB-4D79-4756-A776-C7BB63D30A4F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4868FD55-C56D-445C-9F83-A063302EC78F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4868FD55-C56D-445C-9F83-A063302EC78F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4868FD55-C56D-445C-9F83-A063302EC78F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4868FD55-C56D-445C-9F83-A063302EC78F}.Release|Any CPU.Build.0 = Release|Any CPU
{729A12AB-4D79-4756-A776-C7BB63D30A4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{729A12AB-4D79-4756-A776-C7BB63D30A4F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{729A12AB-4D79-4756-A776-C7BB63D30A4F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{729A12AB-4D79-4756-A776-C7BB63D30A4F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E2F590CA-47E0-4145-924B-3E398540BA45}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[dotnet.test.runner]
name= "Microsoft.Testing.Platform"
Original file line number Diff line number Diff line change
Expand Up @@ -345,17 +345,23 @@ public void RunOnProjectWithSolutionFile_ShouldReturnExitCodeGenericFailure(stri
result.ExitCode.Should().Be(ExitCodes.GenericFailure);
}

[InlineData(TestingConstants.Debug)]
[InlineData(TestingConstants.Release)]
[Theory]
public void RunOnProjectWithClassLibrary_ShouldReturnExitCodeSuccess(string configuration)
[CombinatorialData]
public void RunOnProjectWithClassLibrary_ShouldReturnExitCodeSuccess(
[CombinatorialValues(TestingConstants.Debug, TestingConstants.Release)] string configuration,
[CombinatorialValues("TestProjectWithClassLibrary", "TestProjectWithClassLibraryDifferentTFMs")] string assetName,
bool useFrameworkOption)
{
TestAsset testInstance = _testAssetsManager.CopyTestAsset("TestProjectWithClassLibrary", Guid.NewGuid().ToString())
TestAsset testInstance = _testAssetsManager.CopyTestAsset(assetName, Guid.NewGuid().ToString())
.WithSource();

string[] args = useFrameworkOption
? new[] { TestingPlatformOptions.ConfigurationOption.Name, configuration, TestingPlatformOptions.FrameworkOption.Name, ToolsetInfo.CurrentTargetFramework }
: new[] { TestingPlatformOptions.ConfigurationOption.Name, configuration };

CommandResult result = new DotnetTestCommand(Log, disableNewOutput: false)
.WithWorkingDirectory(testInstance.Path)
.Execute(TestingPlatformOptions.ConfigurationOption.Name, configuration);
.Execute(args);

if (!TestContext.IsLocalized())
{
Expand Down