Add mstest support (#4572)
* Migrate: auto-injected dependencies should overwrite existing dependency version if present * WIP adding new mstest templates * Auto-inject mstest dependencies when testrunner is set to mstest * WIP trying to get new web test to work * Get dotnet new -t Web test to pass * Remove whitespace and accidentally added (redundant) tests * Shorten test method name
This commit is contained in:
parent
80ec02b4da
commit
d1772f6ed4
10 changed files with 169 additions and 24 deletions
|
@ -269,7 +269,7 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
""frameworks"": {
|
||||
""netcoreapp1.0"": {}
|
||||
},
|
||||
""testRunner"": ""mstest""
|
||||
""testRunner"": ""somerunner""
|
||||
}");
|
||||
|
||||
mockProj.Items.Should().ContainSingle(
|
||||
|
@ -282,6 +282,12 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
|
||||
mockProj.Items.Should().NotContain(
|
||||
i => (i.Include == "xunit.runner.visualstudio" && i.ItemType == "PackageReference"));
|
||||
|
||||
mockProj.Items.Should().NotContain(
|
||||
i => (i.Include == "MSTest.TestAdapter" && i.ItemType == "PackageReference"));
|
||||
|
||||
mockProj.Items.Should().NotContain(
|
||||
i => (i.Include == "MSTest.TestFramework" && i.ItemType == "PackageReference"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -312,6 +318,12 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
i => (i.Include == "xunit.runner.visualstudio" &&
|
||||
i.ItemType == "PackageReference" &&
|
||||
i.GetMetadataWithName("Version").Value == "2.2.0-beta4-build1188"));
|
||||
|
||||
mockProj.Items.Should().NotContain(
|
||||
i => (i.Include == "MSTest.TestAdapter" && i.ItemType == "PackageReference"));
|
||||
|
||||
mockProj.Items.Should().NotContain(
|
||||
i => (i.Include == "MSTest.TestFramework" && i.ItemType == "PackageReference"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
@ -345,6 +357,48 @@ namespace Microsoft.DotNet.ProjectJsonMigration.Tests
|
|||
i => (i.Include == "xunit.runner.visualstudio" &&
|
||||
i.ItemType == "PackageReference" &&
|
||||
i.GetMetadataWithName("Version").Value == "2.2.0-beta4-build1188"));
|
||||
|
||||
mockProj.Items.Should().NotContain(
|
||||
i => (i.Include == "MSTest.TestAdapter" && i.ItemType == "PackageReference"));
|
||||
|
||||
mockProj.Items.Should().NotContain(
|
||||
i => (i.Include == "MSTest.TestFramework" && i.ItemType == "PackageReference"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void It_migrates_test_projects_to_have_test_sdk_and_mstest_packagedependencies()
|
||||
{
|
||||
var mockProj = RunPackageDependenciesRuleOnPj(@"
|
||||
{
|
||||
""buildOptions"": {
|
||||
""emitEntryPoint"": true
|
||||
},
|
||||
""frameworks"": {
|
||||
""netcoreapp1.0"": {}
|
||||
},
|
||||
""testRunner"": ""mstest""
|
||||
}");
|
||||
|
||||
mockProj.Items.Should().ContainSingle(
|
||||
i => (i.Include == "Microsoft.NET.Test.Sdk" &&
|
||||
i.ItemType == "PackageReference" &&
|
||||
i.GetMetadataWithName("Version").Value == "15.0.0-preview-20161024-02"));
|
||||
|
||||
mockProj.Items.Should().ContainSingle(
|
||||
i => (i.Include == "MSTest.TestAdapter" &&
|
||||
i.ItemType == "PackageReference" &&
|
||||
i.GetMetadataWithName("Version").Value == "1.1.3-preview"));
|
||||
|
||||
mockProj.Items.Should().ContainSingle(
|
||||
i => (i.Include == "MSTest.TestFramework" &&
|
||||
i.ItemType == "PackageReference" &&
|
||||
i.GetMetadataWithName("Version").Value == "1.0.4-preview"));
|
||||
|
||||
mockProj.Items.Should().NotContain(
|
||||
i => (i.Include == "xunit" && i.ItemType == "PackageReference"));
|
||||
|
||||
mockProj.Items.Should().NotContain(
|
||||
i => (i.Include == "xunit.runner.visualstudio" && i.ItemType == "PackageReference"));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
|
|
|
@ -13,33 +13,32 @@ using FluentAssertions;
|
|||
|
||||
namespace Microsoft.DotNet.New.Tests
|
||||
{
|
||||
public class GivenThatIWantANewCSLibrary : TestBase
|
||||
public class GivenThatIWantANewCSAppWithSpecifiedType : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public void When_library_created_Then_project_restores()
|
||||
[Theory]
|
||||
[InlineData("Console", false)]
|
||||
[InlineData("Lib", false)]
|
||||
[InlineData("Web", true)]
|
||||
[InlineData("Mstest", false)]
|
||||
[InlineData("XUnittest", false)]
|
||||
public void When_dotnet_build_is_invoked_then_project_restores_and_builds_without_warnings(
|
||||
string projectType,
|
||||
bool useNuGetConfigForAspNet)
|
||||
{
|
||||
var rootPath = TestAssetsManager.CreateTestDirectory().Path;
|
||||
var rootPath = TestAssetsManager.CreateTestDirectory(callingMethod: "i").Path;
|
||||
|
||||
new TestCommand("dotnet") { WorkingDirectory = rootPath }
|
||||
.Execute("new --type lib")
|
||||
.Execute($"new --type {projectType}")
|
||||
.Should().Pass();
|
||||
|
||||
|
||||
if (useNuGetConfigForAspNet)
|
||||
{
|
||||
File.Copy("NuGet.tempaspnetpatch.config", Path.Combine(rootPath, "NuGet.Config"));
|
||||
}
|
||||
|
||||
new TestCommand("dotnet") { WorkingDirectory = rootPath }
|
||||
.Execute("restore /p:SkipInvalidConfigurations=true")
|
||||
.Execute($"restore /p:SkipInvalidConfigurations=true")
|
||||
.Should().Pass();
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void When_dotnet_build_is_invoked_Then_library_builds_without_warnings()
|
||||
{
|
||||
var rootPath = TestAssetsManager.CreateTestDirectory().Path;
|
||||
|
||||
new TestCommand("dotnet") { WorkingDirectory = rootPath }
|
||||
.Execute("new --type lib");
|
||||
|
||||
new TestCommand("dotnet") { WorkingDirectory = rootPath }
|
||||
.Execute("restore /p:SkipInvalidConfigurations=true");
|
||||
|
||||
var buildResult = new TestCommand("dotnet")
|
||||
.WithWorkingDirectory(rootPath)
|
11
test/dotnet-new.Tests/NuGet.tempaspnetpatch.config
Normal file
11
test/dotnet-new.Tests/NuGet.tempaspnetpatch.config
Normal file
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
|
||||
<clear />
|
||||
<add key="cli-deps" value="https://dotnet.myget.org/F/cli-deps/api/v3/index.json" />
|
||||
<add key="aspnet101" value="https://www.myget.org/F/aspnet101/api/v3/index.json" />
|
||||
<add key="dotnet-web" value="https://dotnet.myget.org/F/dotnet-web/api/v3/index.json" />
|
||||
<add key="api.nuget.org" value="https://api.nuget.org/v3/index.json" />
|
||||
</packageSources>
|
||||
</configuration>
|
Loading…
Add table
Add a link
Reference in a new issue