Skip to content

Commit

Permalink
Fix crash when 'run selected tests' but no tests are selected
Browse files Browse the repository at this point in the history
  • Loading branch information
rowo360 committed Oct 13, 2024
1 parent 6971c79 commit a5ed7e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,8 @@ private void RunAllTests()
private void RunSelectedTests()
{
var testSelection = _model.SelectedTests;
_model.RunTests(testSelection);
if (testSelection != null)
_model.RunTests(testSelection);
}

private void RunFailedTests()
Expand Down
12 changes: 10 additions & 2 deletions src/TestCentric/tests/Presenters/Main/CommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,17 @@ public void RunAllButton_RunsAllTests()
[Test]
public void RunButton_RunsSelectedTests()
{
// TODO: Specify Results and test with specific argument
var testSelection = new TestSelection();
_model.SelectedTests = testSelection;
_view.RunSelectedButton.Execute += Raise.Event<CommandHandler>();
_model.Received().RunTests(Arg.Any<TestSelection>());
_model.Received().RunTests(testSelection);
}

[Test]
public void RunButton_NoTestSelected_DidnotRunTests()
{
_view.RunSelectedButton.Execute += Raise.Event<CommandHandler>();
_model.DidNotReceiveWithAnyArgs().RunTests(Arg.Any<TestSelection>());
}

[Test]
Expand Down

0 comments on commit a5ed7e9

Please sign in to comment.