Skip to content

Commit

Permalink
Merge pull request #26 from nunit/issue-23
Browse files Browse the repository at this point in the history
Only run exes when using NUnitLiteRunner
  • Loading branch information
CharliePoole authored Sep 10, 2024
2 parents 699832b + eb81e71 commit cd5348b
Showing 1 changed file with 7 additions and 5 deletions.
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

0 comments on commit cd5348b

Please sign in to comment.