Skip to content

Commit

Permalink
Fixacceptancetests (#1157)
Browse files Browse the repository at this point in the history
* Fixes acceptance tests after nunit 4

* Added net 8 sdk

* Update setup-dotnet action to v4

* Cleanup code

* Fixing azure pipeline

* Fix linux build of azure pipelines

* Update linux
  • Loading branch information
OsirisTerje committed Apr 7, 2024
1 parent 578d341 commit 39b5cd4
Show file tree
Hide file tree
Showing 7 changed files with 183 additions and 167 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/NUnit3TestAdapter.Cake.CI.yml
Expand Up @@ -9,13 +9,14 @@ jobs:

steps:
- uses: actions/checkout@v4.1.1
- uses: actions/setup-dotnet@v2
- uses: actions/setup-dotnet@v4
with:
dotnet-version: |
3.1.x
5.0.x
6.0.x
7.0.x
8.0.x
- name: Build with cake
run: .\build.ps1 -t CI
shell: pwsh
11 changes: 10 additions & 1 deletion azure-pipelines.yml
Expand Up @@ -21,6 +21,10 @@ jobs:
displayName: Install .NET Core 7.0 sdk
inputs:
version: 7.x
- task: UseDotNet@2
displayName: Install .NET Core 8.0 sdk
inputs:
version: 8.x
- task: UseDotNet@2
displayName: Install .NET Core 3.1 runtime
inputs:
Expand All @@ -44,6 +48,11 @@ jobs:
inputs:
version: 7.x

- task: UseDotNet@2
displayName: Install .NET Core 8.0 sdk
inputs:
version: 8.x

- task: UseDotNet@2
displayName: Install .NET Core 5.0 runtime
inputs:
Expand All @@ -56,5 +65,5 @@ jobs:
packageType: runtime
version: 3.1.x

- powershell: .\build.ps1 --target=Acceptance --configuration=$(BuildConfiguration)
- powershell: .\build.ps1 --target=test --configuration=$(BuildConfiguration)
displayName: Build and test
96 changes: 94 additions & 2 deletions src/NUnit.TestAdapter.Tests.Acceptance/AcceptanceTests.cs
Expand Up @@ -3,6 +3,7 @@
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;

using NUnit.Framework;
using NUnit.Framework.Interfaces;
Expand All @@ -16,6 +17,7 @@ public class Frameworks
public const string Net50 = "net5.0";
public const string Net60 = "net6.0";
public const string Net70 = "net7.0";
public const string Net80 = "net8.0";
}

[Category("Acceptance")]
Expand All @@ -28,20 +30,110 @@ public abstract class AcceptanceTests
public const string LowestNetfxTarget = "net462";
public const string LegacyProjectTargetFrameworkVersion = "v4.6.2";

public static IEnumerable<string> TargetFrameworks => new[]
protected static IEnumerable<string> TargetFrameworks => new[]
{
LowestNetfxTarget,
Frameworks.NetCoreApp31
};

public static IEnumerable<string> DotNetCliTargetFrameworks => new[]
protected static IEnumerable<string> DotNetCliTargetFrameworks => new[]
{
Frameworks.NetCoreApp31,
Frameworks.Net50,
Frameworks.Net60,
Frameworks.Net70
};

protected static IEnumerable<string> ModernDotNetCliTargetFrameworks => new[]
{
Frameworks.Net60,
Frameworks.Net70,
Frameworks.Net80
};

protected static string NUnit3 => "3.*";
protected static string NUnit4 => "4.*";

public class MultiFrameworkSource
{
public IEnumerable<string> Frameworks { get; set; } = DotNetCliTargetFrameworks;
public string NUnitVersion { get; set; } = NUnit3;

public static IEnumerable<MultiFrameworkSource> LegacyDotNetFrameworks => new List<MultiFrameworkSource> { new() };

public static IEnumerable<MultiFrameworkSource> ModernDotNetFrameworks => new List<MultiFrameworkSource>
{
new ()
{
Frameworks = ModernDotNetCliTargetFrameworks,
NUnitVersion = NUnit4
}
};

public static IEnumerable<MultiFrameworkSource> NetFxFrameworks => new List<MultiFrameworkSource>
{
new ()
{
Frameworks = new List<string> { LowestNetfxTarget },
NUnitVersion = NUnit4
}
};

public static IEnumerable<MultiFrameworkSource> AllFrameworks => LegacyDotNetFrameworks.Concat(ModernDotNetFrameworks).Concat(NetFxFrameworks);
}

public class SingleFrameworkSource
{
public string Framework { get; set; } = LowestNetfxTarget;
public string NUnitVersion { get; set; } = NUnit4;

public static IEnumerable<SingleFrameworkSource> NetFxFramework => new List<SingleFrameworkSource> { new() };

public static IEnumerable<SingleFrameworkSource> LegacyDotNetFramework => new List<SingleFrameworkSource>
{
new ()
{
Framework = Frameworks.NetCoreApp31,
NUnitVersion = NUnit3
},
new ()
{
Framework = Frameworks.Net50,
NUnitVersion = NUnit3
}
};

public static IEnumerable<SingleFrameworkSource> ModernDotNetFramework => new List<SingleFrameworkSource>
{
new ()
{
Framework = Frameworks.Net60,
NUnitVersion = NUnit4
},
new ()
{
Framework = Frameworks.Net70,
NUnitVersion = NUnit4
},
new ()
{
Framework = Frameworks.Net80,
NUnitVersion = NUnit4
}
};

public static IEnumerable<SingleFrameworkSource> AllFrameworks => NetFxFramework.Concat(LegacyDotNetFramework).Concat(ModernDotNetFramework);
public static IEnumerable<SingleFrameworkSource> AllFrameworksExceptNetFx => LegacyDotNetFramework.Concat(ModernDotNetFramework);
}

protected string NUnitVersion(string targetFramework) =>
targetFramework switch
{
Frameworks.NetCoreApp31
or Frameworks.Net50 => NUnit3,
_ => NUnit4,
};

private static readonly Lazy<(IsolatedWorkspaceManager Manager, string NupkgVersion, bool KeepWorkspaces)> Initialization = new(() =>
{
var directory = TestContext.Parameters["ProjectWorkspaceDirectory"]
Expand Down
Expand Up @@ -19,7 +19,7 @@ public static void User_tests_get_the_version_of_Mono_Cecil_referenced_from_the_
<ItemGroup>
<PackageReference Include='Microsoft.NET.Test.Sdk' Version='*' />
<PackageReference Include='Mono.Cecil' Version='0.10.0-beta5' />
<PackageReference Include='NUnit' Version='*' />
<PackageReference Include='NUnit' Version='3.*' />
<PackageReference Include='NUnit3TestAdapter' Version='{NuGetPackageVersion}' />
</ItemGroup>
Expand Down Expand Up @@ -72,7 +72,7 @@ public static void Engine_uses_its_bundled_version_of_Mono_Cecil_instead_of_the_
<ItemGroup>
<PackageReference Include='Microsoft.NET.Test.Sdk' Version='*' />
<PackageReference Include='Mono.Cecil' Version='0.10.0' />
<PackageReference Include='NUnit' Version='*' />
<PackageReference Include='NUnit' Version='3.*' />
<PackageReference Include='NUnit3TestAdapter' Version='{NuGetPackageVersion}' />
</ItemGroup>
<ItemGroup Condition=""'$(TargetFrameworkIdentifier)' == '.NETFramework'"">
Expand Down
Expand Up @@ -21,7 +21,7 @@ protected IsolatedWorkspace CreateTestWorkspace(string framework)
<ItemGroup>
<PackageReference Include='Microsoft.NET.Test.Sdk' Version='*' />
<PackageReference Include='NUnit' Version='*' />
<PackageReference Include='NUnit' Version='{NUnitVersion(framework)}' />
<PackageReference Include='NUnit3TestAdapter' Version='{NuGetPackageVersion}' />
</ItemGroup>
Expand Down

0 comments on commit 39b5cd4

Please sign in to comment.