2016-04-14 22:59:11 +00:00
|
|
|
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
|
|
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
2016-05-03 20:09:27 +00:00
|
|
|
|
using System.Runtime.CompilerServices;
|
2016-04-28 23:30:32 +00:00
|
|
|
|
using FluentAssertions;
|
|
|
|
|
using Microsoft.DotNet.InternalAbstractions;
|
2016-08-09 18:05:00 +00:00
|
|
|
|
using Microsoft.DotNet.PlatformAbstractions;
|
2016-04-14 22:59:11 +00:00
|
|
|
|
using Microsoft.DotNet.ProjectModel;
|
|
|
|
|
using Microsoft.DotNet.TestFramework;
|
|
|
|
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.Dotnet.Tools.Test.Tests
|
|
|
|
|
{
|
|
|
|
|
public class GivenThatWeWantToUseDotnetTestE2EInDesignTimeForMultipleTFms : TestBase
|
|
|
|
|
{
|
2016-05-03 20:09:27 +00:00
|
|
|
|
private string _projectFilePath;
|
|
|
|
|
private string _netCoreAppOutputPath;
|
|
|
|
|
private string _net451OutputPath;
|
2016-04-14 22:59:11 +00:00
|
|
|
|
|
2016-05-03 20:09:27 +00:00
|
|
|
|
private void Setup([CallerMemberName] string callingMethod = "")
|
2016-04-14 22:59:11 +00:00
|
|
|
|
{
|
2016-05-03 20:09:27 +00:00
|
|
|
|
var testInstance = TestAssetsManager.CreateTestInstance(Path.Combine("ProjectsWithTests", "MultipleFrameworkProject"), callingMethod);
|
2016-04-14 22:59:11 +00:00
|
|
|
|
|
|
|
|
|
_projectFilePath = Path.Combine(testInstance.TestRoot, "project.json");
|
|
|
|
|
var contexts = ProjectContext.CreateContextForEachFramework(
|
|
|
|
|
_projectFilePath,
|
|
|
|
|
null,
|
2016-04-28 23:30:32 +00:00
|
|
|
|
RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers());
|
2016-04-14 22:59:11 +00:00
|
|
|
|
|
|
|
|
|
// Restore the project again in the destination to resolve projects
|
|
|
|
|
// Since the lock file has project relative paths in it, those will be broken
|
|
|
|
|
// unless we re-restore
|
|
|
|
|
new RestoreCommand() { WorkingDirectory = testInstance.TestRoot }.Execute().Should().Pass();
|
|
|
|
|
|
|
|
|
|
_netCoreAppOutputPath = Path.Combine(testInstance.TestRoot, "bin", "Debug", "netcoreapp1.0");
|
|
|
|
|
var buildCommand = new BuildCommand(_projectFilePath);
|
|
|
|
|
var result = buildCommand.Execute($"-f netcoreapp1.0 -o {_netCoreAppOutputPath}");
|
|
|
|
|
|
|
|
|
|
result.Should().Pass();
|
|
|
|
|
|
2016-04-28 23:30:32 +00:00
|
|
|
|
if (RuntimeEnvironment.OperatingSystemPlatform == Platform.Windows)
|
2016-04-14 22:59:11 +00:00
|
|
|
|
{
|
2016-04-28 23:30:32 +00:00
|
|
|
|
var rid = RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers().First();
|
2016-04-14 22:59:11 +00:00
|
|
|
|
_net451OutputPath = Path.Combine(testInstance.TestRoot, "bin", "Debug", "net451", rid);
|
|
|
|
|
result = buildCommand.Execute($"-f net451 -r {rid} -o {_net451OutputPath}");
|
|
|
|
|
result.Should().Pass();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[WindowsOnlyFact]
|
|
|
|
|
public void It_discovers_tests_for_the_ProjectWithTestsWithNetCoreApp()
|
|
|
|
|
{
|
2016-05-03 20:09:27 +00:00
|
|
|
|
Setup();
|
|
|
|
|
|
2016-04-14 22:59:11 +00:00
|
|
|
|
using (var adapter = new Adapter("TestDiscovery.Start"))
|
|
|
|
|
{
|
|
|
|
|
adapter.Listen();
|
|
|
|
|
|
|
|
|
|
var testCommand = new DotnetTestCommand();
|
|
|
|
|
var result = testCommand.Execute($"{_projectFilePath} -f netcoreapp1.0 -o {_netCoreAppOutputPath} --port {adapter.Port} --no-build");
|
|
|
|
|
result.Should().Pass();
|
|
|
|
|
|
|
|
|
|
adapter.Messages["TestSession.Connected"].Count.Should().Be(1);
|
|
|
|
|
adapter.Messages["TestDiscovery.TestFound"].Count.Should().Be(4);
|
|
|
|
|
adapter.Messages["TestDiscovery.Completed"].Count.Should().Be(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-10 20:39:08 +00:00
|
|
|
|
[WindowsOnlyFact(Skip="https://github.com/xunit/xunit/issues/934")]
|
2016-04-14 22:59:11 +00:00
|
|
|
|
public void It_discovers_tests_for_the_ProjectWithTestsWithNet451()
|
|
|
|
|
{
|
2016-05-03 20:09:27 +00:00
|
|
|
|
Setup();
|
|
|
|
|
|
2016-04-14 22:59:11 +00:00
|
|
|
|
using (var adapter = new Adapter("TestDiscovery.Start"))
|
|
|
|
|
{
|
|
|
|
|
adapter.Listen();
|
2016-04-28 23:30:32 +00:00
|
|
|
|
var rid = RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers().First();
|
2016-04-14 22:59:11 +00:00
|
|
|
|
|
|
|
|
|
var testCommand = new DotnetTestCommand();
|
|
|
|
|
var result = testCommand.Execute($"{_projectFilePath} -f net451 -r {rid} -o {_net451OutputPath} --port {adapter.Port} --no-build");
|
|
|
|
|
result.Should().Pass();
|
|
|
|
|
|
|
|
|
|
adapter.Messages["TestSession.Connected"].Count.Should().Be(1);
|
|
|
|
|
adapter.Messages["TestDiscovery.TestFound"].Count.Should().Be(4);
|
|
|
|
|
adapter.Messages["TestDiscovery.Completed"].Count.Should().Be(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void It_runs_tests_for_netcoreapp10()
|
|
|
|
|
{
|
2016-05-03 20:09:27 +00:00
|
|
|
|
Setup();
|
|
|
|
|
|
2016-04-14 22:59:11 +00:00
|
|
|
|
using (var adapter = new Adapter("TestExecution.GetTestRunnerProcessStartInfo"))
|
|
|
|
|
{
|
|
|
|
|
adapter.Listen();
|
|
|
|
|
|
|
|
|
|
var testCommand = new DotnetTestCommand();
|
|
|
|
|
var result = testCommand.Execute($"{_projectFilePath} -f netcoreapp1.0 -o {_netCoreAppOutputPath} --port {adapter.Port} --no-build");
|
|
|
|
|
result.Should().Pass();
|
|
|
|
|
|
|
|
|
|
adapter.Messages["TestSession.Connected"].Count.Should().Be(1);
|
|
|
|
|
adapter.Messages["TestExecution.TestRunnerProcessStartInfo"].Count.Should().Be(1);
|
|
|
|
|
adapter.Messages["TestExecution.TestStarted"].Count.Should().Be(4);
|
|
|
|
|
adapter.Messages["TestExecution.TestResult"].Count.Should().Be(4);
|
|
|
|
|
adapter.Messages["TestExecution.Completed"].Count.Should().Be(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-10 20:39:08 +00:00
|
|
|
|
[WindowsOnlyFact(Skip="https://github.com/xunit/xunit/issues/934")]
|
2016-04-14 22:59:11 +00:00
|
|
|
|
public void It_runs_tests_for_net451()
|
|
|
|
|
{
|
2016-05-03 20:09:27 +00:00
|
|
|
|
Setup();
|
|
|
|
|
|
2016-04-14 22:59:11 +00:00
|
|
|
|
using (var adapter = new Adapter("TestExecution.GetTestRunnerProcessStartInfo"))
|
|
|
|
|
{
|
|
|
|
|
adapter.Listen();
|
|
|
|
|
|
|
|
|
|
var testCommand = new DotnetTestCommand();
|
2016-04-28 23:30:32 +00:00
|
|
|
|
var rid = RuntimeEnvironmentRidExtensions.GetAllCandidateRuntimeIdentifiers().First();
|
2016-04-14 22:59:11 +00:00
|
|
|
|
var result = testCommand.Execute($"{_projectFilePath} -f net451 -r {rid} -o {_net451OutputPath} --port {adapter.Port} --no-build");
|
|
|
|
|
result.Should().Pass();
|
|
|
|
|
|
|
|
|
|
adapter.Messages["TestSession.Connected"].Count.Should().Be(1);
|
|
|
|
|
adapter.Messages["TestExecution.TestRunnerProcessStartInfo"].Count.Should().Be(1);
|
|
|
|
|
adapter.Messages["TestExecution.TestStarted"].Count.Should().Be(4);
|
|
|
|
|
adapter.Messages["TestExecution.TestResult"].Count.Should().Be(4);
|
|
|
|
|
adapter.Messages["TestExecution.Completed"].Count.Should().Be(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|