Detect risky PHPUnit test
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start from the issue's try/catch example and review the repository's existing PHPUnit-related rules and tests. Define whether PHPStan should report tests that can finish successfully after the expected Throwable is caught without an explicit failure, then add coverage for the agreed behavior.
Written by the indexing model from the issue text.
Description
Feature request
In the following scenario:
function test_exception_state(): void {
$myService = new MyService();
try {
$myService->doSomethingWrong();
// missing: $this->fail();
} catch (MyException $exception) {
$this->assertSame('Custom message', $exception->getMessage());
$this->assertSame('Another property', $exception->smthNotTypicalOfException);
}
}
Essentially, a case where we want to do an explicit try/catch because expectExceptionObject() doesn't cut it (want to catch a Throwable instead of test some state of the exception besides message/code), it is easy to forget a fail() statement and leading to a risky test.
Maybe it leading as a risky is fine... But maybe it's a kinda of issue that PHPStan could detect & report. Just an idea.
Did PHPStan help you today? Did it make you happy in any way?
Today it did not help, but I didn't run it either so cannot blame it :) I like PHPStan otherwise!
- Dominant language
- PHP
- Stars
- 544
- Forks
- 58
- Avg merge
- 2d 1h
- Merged PRs (30d)
- 5
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from phpstan/phpstan-phpunit
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
phpstan/phpstan-phpunit#332 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
phpstan/phpstan-phpunit#321 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
phpstan/phpstan-phpunit#309 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
phpstan/phpstan-phpunit#299 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 52/100
phpstan/phpstan-phpunit#292 · 3 comments ·
All issues in phpstan/phpstan-phpunit
Similar issues
-
priority: p3
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
googleapis/librarian#7636 ·
-
0. Needs triage bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nextcloud/fulltextsearch#1011 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
coollabsio/coolify#11927 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100