Skip to content

Commit

Permalink
Move to YAML-based build for Azure Pipelines and fix silently skipped…
Browse files Browse the repository at this point in the history
… tests (#666)

* Add Azure Pipelines YAML

* Include acceptance test results in Azure Pipelines

* Name each test run

* Invalid path was built with `netcoreapp`  instead of `netcoreapp2.1`

* Include 'dotnet test' results in uploaded TestResults folder

* 'dotnet test' skips .NET Framework projects unless they have <IsTestProject>

* Set the test run names for uploaded test results
  • Loading branch information
jnm2 authored and OsirisTerje committed Oct 21, 2019
1 parent 65cc406 commit bddee2c
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 8 deletions.
25 changes: 25 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
trigger:
branches:
include: [ '*' ]
exclude: [ 'refs/tags/*' ]

pool:
vmImage: windows-latest

steps:
- powershell: .\build.ps1 --target=CI --configuration=$(BuildConfiguration)
displayName: Build, package, and test

- task: PublishBuildArtifacts@1
displayName: Publish bin artifacts
inputs:
PathtoPublish: $(build.sourcesdirectory)\bin\$(BuildConfiguration)
ArtifactName: Bin
condition: succeededOrFailed()

- task: PublishBuildArtifacts@1
displayName: Publish package artifacts
inputs:
PathtoPublish: $(build.sourcesdirectory)\package
ArtifactName: Package
condition: succeededOrFailed()
43 changes: 35 additions & 8 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ var BIN_DIR = PROJECT_DIR + "bin/" + configuration + "/";
var ADAPTER_PROJECT = SRC_DIR + "NUnitTestAdapter/NUnit.TestAdapter.csproj";

var NETCOREAPP_TFM = "netcoreapp2.1";
var VSTEST_NETCOREAPP_FRAMEWORK = "netcoreapp2.1";

var ADAPTER_BIN_DIR_NET35 = SRC_DIR + $"NUnitTestAdapter/bin/{configuration}/net35/";
var ADAPTER_BIN_DIR_NETCOREAPP = SRC_DIR + $"NUnitTestAdapter/bin/{configuration}/{NETCOREAPP_TFM}/";
Expand Down Expand Up @@ -147,7 +146,7 @@ string GetTestAssemblyPath(string framework)

foreach (var (framework, vstestFramework, adapterDir) in new[] {
("net46", "Framework45", ADAPTER_BIN_DIR_NET35),
("netcoreapp", VSTEST_NETCOREAPP_FRAMEWORK, ADAPTER_BIN_DIR_NETCOREAPP)
(NETCOREAPP_TFM, NETCOREAPP_TFM, ADAPTER_BIN_DIR_NETCOREAPP)
})
{
Task($"VSTest-{framework}")
Expand All @@ -160,9 +159,13 @@ foreach (var (framework, vstestFramework, adapterDir) in new[] {
// Enables the tests to run against the correct version of Microsoft.VisualStudio.TestPlatform.ObjectModel.dll.
// (The DLL they are compiled against depends on VS2012 at runtime.)
SettingsFile = File("DisableAppDomain.runsettings"),
Logger = "trx"
Logger = $"trx;LogFileName=VSTest-{framework}.trx"
});
PublishTestResults($"VSTest-{framework}.trx");
});



Task($"DotnetTest-{framework}")
.IsDependentOn("Build")
Expand All @@ -175,9 +178,27 @@ foreach (var (framework, vstestFramework, adapterDir) in new[] {
NoBuild = true,
TestAdapterPath = adapterDir,
Settings = File("DisableAppDomain.runsettings"),
Logger="trx"
Logger = $"trx;LogFileName=DotnetTest-{framework}.trx",
ResultsDirectory = MakeAbsolute(Directory("TestResults"))
});
PublishTestResults($"DotnetTest-{framework}.trx");
});
}

void PublishTestResults(string fileName)
{
if (EnvironmentVariable("TF_BUILD", false))
{
TFBuild.Commands.PublishTestResults(new TFBuildPublishTestResultsData
{
TestResultsFiles = { @"TestResults\" + fileName },
TestRunTitle = fileName,
TestRunner = TFTestRunnerType.VSTest,
PublishRunAttachments = true,
Configuration = configuration
});
}
}

//////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -261,9 +282,9 @@ Task("Rebuild")

Task("Test")
.IsDependentOn("VSTest-net46")
.IsDependentOn("VSTest-netcoreapp")
.IsDependentOn("VSTest-" + NETCOREAPP_TFM)
.IsDependentOn("DotnetTest-net46")
.IsDependentOn("DotnetTest-netcoreapp");
.IsDependentOn("DotnetTest-" + NETCOREAPP_TFM);

Task("Package")
.IsDependentOn("PackageZip")
Expand All @@ -282,16 +303,22 @@ Task("Acceptance")
VSTest(testAssembly, new VSTestSettings
{
SettingsFile = keepWorkspaces ? (FilePath)"KeepWorkspaces.runsettings" : null
SettingsFile = keepWorkspaces ? (FilePath)"KeepWorkspaces.runsettings" : null,
Logger = "trx;LogFileName=Acceptance.trx"
});
PublishTestResults("Acceptance.trx");
});

Task("Appveyor")
Task("CI")
.IsDependentOn("Build")
.IsDependentOn("Test")
.IsDependentOn("Package")
.IsDependentOn("Acceptance");

Task("Appveyor")
.IsDependentOn("CI");

Task("Default")
.IsDependentOn("Build");

Expand Down
1 change: 1 addition & 0 deletions src/NUnitTestAdapterTests/NUnit.TestAdapter.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<IsTestProject>true</IsTestProject>
<RootNamespace>NUnit.VisualStudio.TestAdapter.Tests</RootNamespace>
<AssemblyName>NUnit.VisualStudio.TestAdapter.Tests</AssemblyName>
<TargetFrameworks>net46;netcoreapp2.1</TargetFrameworks>
Expand Down

0 comments on commit bddee2c

Please sign in to comment.