Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only run exes when using NUnitLiteRunner #26

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions recipe/unit-testing.cake
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
public static class UnitTesting
{
static ICakeContext _context;
static IUnitTestRunner _runner;

static UnitTesting()
{
_context = BuildSettings.Context;
_runner = BuildSettings.UnitTestRunner ?? new NUnitLiteRunner();
}

public static void RunAllTests()
Expand All @@ -17,9 +19,7 @@ public static class UnitTesting

_context.Information($"Located {unitTests.Count} unit test assemblies.");
var errors = new List<string>();

var runner = BuildSettings.UnitTestRunner ?? new NUnitLiteRunner();


foreach (var testPath in unitTests)
{
var testFile = testPath.GetFilename();
Expand All @@ -30,7 +30,7 @@ public static class UnitTesting
? $"Running {testFile} under {runtime}"
: $"Running {testFile}");

int rc = runner.RunUnitTest(testPath);
int rc = _runner.RunUnitTest(testPath);

var name = runtime != null
? $"{testFile}({runtime})"
Expand Down Expand Up @@ -76,7 +76,9 @@ public static class UnitTesting
{
// Use default patterns to find unit tests - case insensitive because
// we don't know how the user may have named test assemblies.
var defaultPatterns = new [] { "**/*.tests.dll", "**/*.tests.exe" };
var defaultPatterns = _runner is NUnitLiteRunner
? new[] { "**/*.tests.exe" }
: new[] { "**/*.tests.dll", "**/*.tests.exe" };
var globberSettings = new GlobberSettings { IsCaseSensitive = false };
foreach (string filePattern in defaultPatterns)
foreach (var testPath in _context.GetFiles(BuildSettings.OutputDirectory + filePattern, globberSettings))
Expand Down