-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Downgrade externals - tests for test platform nuget (#2649)
* Downgrade externals - tests for test platform nuget * uncomment * Add back interop for signing * Downgrade even more * Fixing tests
- Loading branch information
Showing
7 changed files
with
137 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
test/Microsoft.TestPlatform.AcceptanceTests/TestPlatformNugetPackageTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Microsoft.TestPlatform.AcceptanceTests | ||
{ | ||
using System; | ||
using System.IO; | ||
using System.IO.Compression; | ||
using System.Linq; | ||
|
||
using Microsoft.TestPlatform.TestUtilities; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
[TestClass] | ||
public class TestPlatformNugetPackageTests : CodeCoverageAcceptanceTestBase | ||
{ | ||
private static string nugetPackageFolder; | ||
private string resultsDirectory; | ||
|
||
[ClassInitialize] | ||
public static void ClassInit(TestContext testContext) | ||
{ | ||
var packageLocation = Path.Combine(IntegrationTestEnvironment.TestPlatformRootDirectory, "artifacts", IntegrationTestEnvironment.BuildConfiguration, "packages"); | ||
var nugetPackage = Directory.EnumerateFiles(packageLocation, "Microsoft.TestPlatform.*.nupkg").OrderBy(a => a).FirstOrDefault(); | ||
nugetPackageFolder = Path.Combine(packageLocation, Path.GetFileNameWithoutExtension(nugetPackage)); | ||
ZipFile.ExtractToDirectory(nugetPackage, nugetPackageFolder); | ||
|
||
Directory.Move(Path.Combine(nugetPackageFolder, "tools", "net451", "Team%20Tools"), Path.Combine(nugetPackageFolder, "tools", "net451", "Team Tools")); | ||
Directory.Move(Path.Combine(nugetPackageFolder, "tools", "net451", "Team Tools", "Dynamic%20Code%20Coverage%20Tools"), Path.Combine(nugetPackageFolder, "tools", "net451", "Team Tools", "Dynamic Code Coverage Tools")); | ||
} | ||
|
||
[ClassCleanup] | ||
public static void ClassCleanup() | ||
{ | ||
Directory.Delete(nugetPackageFolder, true); | ||
} | ||
|
||
[TestInitialize] | ||
public void SetUp() | ||
{ | ||
this.resultsDirectory = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); | ||
} | ||
|
||
[TestCleanup] | ||
public void CleanUp() | ||
{ | ||
Directory.Delete(resultsDirectory, true); | ||
} | ||
|
||
[TestMethod] | ||
[NetFullTargetFrameworkDataSource(useCoreRunner: false)] | ||
[NetCoreTargetFrameworkDataSource(useCoreRunner: false)] | ||
public void RunMultipleTestAssembliesWithCodeCoverage(RunnerInfo runnerInfo) | ||
{ | ||
AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo); | ||
|
||
var assemblyPaths = this.BuildMultipleAssemblyPath("SimpleTestProject.dll", "SimpleTestProject2.dll").Trim('\"'); | ||
|
||
var arguments = CreateCodeCoverageArguments(runnerInfo, assemblyPaths, out var trxFilePath); | ||
this.InvokeVsTest(arguments); | ||
|
||
this.ExitCodeEquals(1); // failing tests | ||
|
||
var actualCoverageFile = CodeCoverageTests.GetCoverageFileNameFromTrx(trxFilePath, resultsDirectory); | ||
Console.WriteLine($@"Coverage file: {actualCoverageFile} Results directory: {resultsDirectory} trxfile: {trxFilePath}"); | ||
Assert.IsTrue(File.Exists(actualCoverageFile), "Coverage file not found: {0}", actualCoverageFile); | ||
} | ||
|
||
public override string GetConsoleRunnerPath() | ||
{ | ||
string consoleRunnerPath = string.Empty; | ||
|
||
if (this.IsDesktopRunner()) | ||
{ | ||
consoleRunnerPath = Path.Combine(nugetPackageFolder, "tools", "net451", "Common7", "IDE", "Extensions", "TestPlatform", "vstest.console.exe"); | ||
} | ||
|
||
Assert.IsTrue(File.Exists(consoleRunnerPath), "GetConsoleRunnerPath: Path not found: {0}", consoleRunnerPath); | ||
return consoleRunnerPath; | ||
} | ||
|
||
private string CreateCodeCoverageArguments( | ||
RunnerInfo runnerInfo, | ||
string assemblyPaths, | ||
out string trxFilePath) | ||
{ | ||
string diagFileName = Path.Combine(this.resultsDirectory, "diaglog.txt"); | ||
|
||
var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, | ||
this.FrameworkArgValue, runnerInfo.InIsolationValue); | ||
|
||
arguments = string.Concat(arguments, $" /ResultsDirectory:{resultsDirectory}", $" /Diag:{diagFileName}", $" /EnableCodeCoverage"); | ||
|
||
trxFilePath = Path.Combine(this.resultsDirectory, Guid.NewGuid() + ".trx"); | ||
arguments = string.Concat(arguments, " /logger:trx;logfilename=" + trxFilePath); | ||
|
||
return arguments; | ||
} | ||
} | ||
} |