diff --git a/src/PendingCalls/TestCall.php b/src/PendingCalls/TestCall.php index 48f612b8..0afdf9d6 100644 --- a/src/PendingCalls/TestCall.php +++ b/src/PendingCalls/TestCall.php @@ -229,6 +229,18 @@ final class TestCall return $this; } + /** + * Informs the test runner that no expectations happen in this test, + * and its purpose is simply to check whether the given code can + * be executed without throwing exceptions. + */ + public function throwsNoExceptions(): TestCall + { + $this->testCaseMethod->proxies->add(Backtrace::file(), Backtrace::line(), 'expectNotToPerformAssertions', []); + + return $this; + } + /** * Saves the property accessors to be used on the target. */ diff --git a/tests/Features/ThrowsNoExceptions.php b/tests/Features/ThrowsNoExceptions.php new file mode 100644 index 00000000..98f38574 --- /dev/null +++ b/tests/Features/ThrowsNoExceptions.php @@ -0,0 +1,11 @@ +expectNotToPerformAssertions(); + + $result = 1 + 1; +}); + +it('allows performing no expectations without being risky', function () { + $result = 1 + 1; +})->throwsNoExceptions();