Is there a way to have a 'before' function before a specific test? #568
Unanswered
grantholle
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Hi @grantholle, You could possibly have something like: <?php
beforeEach(function () {
var_dump('Calls Before Each');
if (str_contains($this->getName(), 'test #2')) {
var_dump('runs only on test 2');
}
});
test('test #1', function () {
expect(true)->toBeTrue();
});
test('test #2', function ($str) {
expect($str)->toBeString();
})->with(['a', 'b']); Resulting in:
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm using datasets (which are amazing!), but I'm running into an issue where I'm trying to test some very specific edge cases on a piece of functionality. I would like the ability to have a
beforeX
function, just before one specific test.Is there a way to do that on a
it()
function directly? The workaround is just to create an entire separate test file, but wondering if there was some sort of hook to do it for an individual test.Beta Was this translation helpful? Give feedback.
All reactions