From eb81e71a795c9df669231193d16e13d17294ed66 Mon Sep 17 00:00:00 2001 From: Charlie Poole Date: Tue, 10 Sep 2024 16:27:47 -0700 Subject: [PATCH] Only run exes when using NUnitLiteRunner --- recipe/unit-testing.cake | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/recipe/unit-testing.cake b/recipe/unit-testing.cake index 24094d0..3180389 100644 --- a/recipe/unit-testing.cake +++ b/recipe/unit-testing.cake @@ -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() @@ -17,9 +19,7 @@ public static class UnitTesting _context.Information($"Located {unitTests.Count} unit test assemblies."); var errors = new List(); - - var runner = BuildSettings.UnitTestRunner ?? new NUnitLiteRunner(); - + foreach (var testPath in unitTests) { var testFile = testPath.GetFilename(); @@ -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})" @@ -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))