cake-build / cake

:cake: Cake (C# Make) is a cross platform build automation system.
https://cakebuild.net
MIT License
3.87k stars 727 forks source link

Demonstrate inconsistent `WithExpectedExitCode` behavior #4080

Open Jericho opened 1 year ago

Jericho commented 1 year ago

I'm submitting this PR to demonstrate the problem I tried to explain in #4013

I have written a unit test that fails due to the problem I described. In short:

Given these facts, I expect Cake to throw an exception but my unit test highlights the fact that this is not happening.

Jericho commented 1 year ago

As I have mentioned, my unit test fails (here):

[xUnit.net 00:00:06.59]     Cake.Common.Tests.Unit.Tools.Command.CommandRunnerTests.Exception_Thrown_when_command_exit_code_is_zero_and_expected_value_is_non_zero [FAIL]
  Failed Cake.Common.Tests.Unit.Tools.Command.CommandRunnerTests.Exception_Thrown_when_command_exit_code_is_zero_and_expected_value_is_non_zero [157 ms]
  Error Message:
   Assert.IsType() Failure
Expected: Cake.Core.CakeException
Actual:   (null)
  Stack Trace:
     at Cake.Common.Tests.Unit.Tools.Command.CommandRunnerTests.Exception_Thrown_when_command_exit_code_is_zero_and_expected_value_is_non_zero() in D:\a\cake\cake\src\Cake.Common.Tests\Unit\Tools\Command\CommandRunnerTests.cs:line 230