diff --git a/src/Stryker.Abstractions/Exceptions/InvalidProjectsException.cs b/src/Stryker.Abstractions/Exceptions/InvalidProjectsException.cs
new file mode 100644
index 000000000..53838efcd
--- /dev/null
+++ b/src/Stryker.Abstractions/Exceptions/InvalidProjectsException.cs
@@ -0,0 +1,24 @@
+using System;
+
+namespace Stryker.Abstractions.Exceptions;
+
+///
+/// Represents error when no test projects are found in the solution or configured for stryker.
+///
+public class InvalidProjectsException : Exception
+{
+ public InvalidProjectsException(string message)
+ : base(message)
+ {
+ }
+
+ public static InvalidProjectsException NoTestProjectsFound()
+ {
+ return new InvalidProjectsException("No test projects found. Please add a test project to your solution or fix your stryker config.");
+ }
+
+ public static InvalidProjectsException OnlyTestProjectsFound()
+ {
+ return new InvalidProjectsException("Only test projects found. Please ensure that your solution contains non-test projects.");
+ }
+}
diff --git a/src/Stryker.Abstractions/Exceptions/NoTestProjectsException.cs b/src/Stryker.Abstractions/Exceptions/NoTestProjectsException.cs
deleted file mode 100644
index b75aea338..000000000
--- a/src/Stryker.Abstractions/Exceptions/NoTestProjectsException.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using System;
-
-namespace Stryker.Abstractions.Exceptions;
-
-///
-/// Represents error when no test projects are found in the solution or configured for stryker.
-///
-public class NoTestProjectsException()
- : Exception("No test projects found. Please add a test project to your solution or fix your stryker config.");
diff --git a/src/Stryker.CLI/Stryker.CLI/Program.cs b/src/Stryker.CLI/Stryker.CLI/Program.cs
index 4dcd06b2d..628030e8f 100644
--- a/src/Stryker.CLI/Stryker.CLI/Program.cs
+++ b/src/Stryker.CLI/Stryker.CLI/Program.cs
@@ -13,7 +13,7 @@ public static int Main(string[] args)
var app = new StrykerCli();
return app.Run(args);
}
- catch (NoTestProjectsException exception)
+ catch (InvalidProjectsException exception)
{
AnsiConsole.WriteLine(exception.Message);
return ExitCodes.Success;
diff --git a/src/Stryker.Core/Stryker.Core.UnitTest/StrykerRunnerTests.cs b/src/Stryker.Core/Stryker.Core.UnitTest/StrykerRunnerTests.cs
index fd2cde8f8..a13e78b05 100644
--- a/src/Stryker.Core/Stryker.Core.UnitTest/StrykerRunnerTests.cs
+++ b/src/Stryker.Core/Stryker.Core.UnitTest/StrykerRunnerTests.cs
@@ -181,7 +181,50 @@ public void ShouldThrow_WhenNoProjectsFound()
var target = new StrykerRunner(reporterFactory: reporterFactoryMock.Object);
- Should.Throw(() => target.RunMutationTest(inputsMock.Object, new LoggerFactory(), projectOrchestratorMock.Object));
+ Should.Throw(() => target.RunMutationTest(inputsMock.Object, new LoggerFactory(), projectOrchestratorMock.Object));
+
+ reporterMock.Verify(x => x.OnStartMutantTestRun(It.IsAny>()), Times.Never);
+ reporterMock.Verify(x => x.OnMutantTested(It.IsAny()), Times.Never);
+ reporterMock.Verify(x => x.OnAllMutantsTested(It.IsAny(), It.IsAny()), Times.Never);
+ }
+
+ [TestMethod]
+ public void ShouldThrow_WhenOnlyTestProjectsFound()
+ {
+ var projectOrchestratorMock = new Mock(MockBehavior.Strict);
+ var reporterFactoryMock = new Mock(MockBehavior.Strict);
+ var reporterMock = new Mock(MockBehavior.Strict);
+ var inputsMock = new Mock(MockBehavior.Strict);
+ var fileSystemMock = new MockFileSystem();
+
+ var folder = new CsharpFolderComposite();
+ folder.Add(new CsharpFileLeaf
+ {
+ Mutants = new Collection() { new Mutant() { Id = 1, ResultStatus = MutantStatus.Ignored } }
+ });
+ var mutationTestInput = new MutationTestInput()
+ {
+ SourceProjectInfo = new SourceProjectInfo()
+ {
+ ProjectContents = folder
+ }
+ };
+
+ inputsMock.Setup(x => x.ValidateAll()).Returns(new StrykerOptions
+ {
+ ProjectPath = "C:/test",
+ OptimizationMode = OptimizationModes.None,
+ LogOptions = new LogOptions()
+ });
+
+ projectOrchestratorMock.Setup(x => x.MutateProjects(It.IsAny(), It.IsAny(), It.IsAny()))
+ .Returns(new List() { });
+
+ reporterFactoryMock.Setup(x => x.Create(It.IsAny(), It.IsAny())).Returns(reporterMock.Object);
+
+ var target = new StrykerRunner(reporterFactory: reporterFactoryMock.Object);
+
+ Should.Throw(() => target.RunMutationTest(inputsMock.Object, new LoggerFactory(), projectOrchestratorMock.Object));
reporterMock.Verify(x => x.OnStartMutantTestRun(It.IsAny>()), Times.Never);
reporterMock.Verify(x => x.OnMutantTested(It.IsAny()), Times.Never);
diff --git a/src/Stryker.Core/Stryker.Core/StrykerRunner.cs b/src/Stryker.Core/Stryker.Core/StrykerRunner.cs
index 0a17f8fd0..8045db822 100644
--- a/src/Stryker.Core/Stryker.Core/StrykerRunner.cs
+++ b/src/Stryker.Core/Stryker.Core/StrykerRunner.cs
@@ -181,7 +181,12 @@ private IReadOnlyProjectComponent AddRootFolderIfMultiProject(IEnumerable pc is TestProject))
+ {
+ throw InvalidProjectsException.OnlyTestProjectsFound();
}
if (projectComponents.Count() > 1)