Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UtilityMethodTestCase::getTargetToken(): throw an exception when delimiter not found #372

Conversation

jrfnl
Copy link
Member

@jrfnl jrfnl commented Oct 17, 2022

PR #273 updated the UtilityMethodTestCase::getTargetToken() method to fail a test with a descriptive error messages when the test marker/delimiter comment could not be found.

This PR is a follow-up to that and instead of outright failing the test, the method will now throw a new, PHPCSUtils native PHPCSUtils\Exceptions\TestMarkerNotFound exception, which extends the PHP native OutOfBoundsException.

Note: the previous change has not been in a tagged release yet.

The reason for making this change is as follows:

  1. The test run will still be marked as unsuccessful, so in that sense, there is no change.
  2. Marking the test as "errored" is semantically more correct as a basic condition for the test to be able to run (precondition for finding the target token) has not been fulfilled.

Includes perfunctory tests for the new TestMarkerNotFound exception. Includes updating the related test in the GetTargetTokenTest class to expect the new exception.

…miter not found

PR 273 updated the  UtilityMethodTestCase::getTargetToken()``method to fail a test with a descriptive error messages when the test marker/delimiter comment could not be found.

This PR is a follow-up to that and instead of outright failing the test, the method will now throw a new, PHPCSUtils native `PHPCSUtils\Exceptions\TestMarkerNotFound` exception, which extends the PHP native `OutOfBoundsException`.

Note: the previous change has not been in a tagged release yet.

The reason for making this change is as follows:
1. The test run will still be marked as unsuccessful, so in that sense, there is no change.
2. Marking the test as "errored" is semantically more correct as a basic condition for the test to be able to run (precondition for finding the target token) has not been fulfilled.

Includes perfunctory tests for the new `TestMarkerNotFound` exception.
Includes updating the related test in the `GetTargetTokenTest` class to expect the new exception.
@jrfnl jrfnl added this to the 1.0.0-alpha4 milestone Oct 17, 2022
@jrfnl jrfnl merged commit 1e41776 into develop Oct 17, 2022
@jrfnl jrfnl deleted the testutils/utilitymethodtestcase-gettargettoken-throw-on-missing-marker branch October 17, 2022 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant