Skip to content
\n

I added the \"if (defined('BEHAT_BIN_PATH'))\" because my bootstrap file is shared between Behat and PHPUnit and of course I don't want that to run when running PHPUnit suite because that is handled automatically by PHPUnit itself.

","upvoteCount":1,"url":"https://github.com/Behat/Behat/discussions/1617#discussioncomment-12748611"}}}

PHPUnit 11 and Assert usage within Behat scenario #1617

Answered by loru88
loru88 asked this question in Q&A
Discussion options

You must be logged in to vote

I think I found a workaround to make Assertion work properly in Behat.
You have to define a bootstrap file and add this piece of code that will create the PHPUnit configuration only if executed in the Behat runtime:

if (defined('BEHAT_BIN_PATH')) {
    (new \PHPUnit\TextUI\Configuration\Builder())->build([]);
}

I added the "if (defined('BEHAT_BIN_PATH'))" because my bootstrap file is shared between Behat and PHPUnit and of course I don't want that to run when running PHPUnit suite because that is handled automatically by PHPUnit itself.

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
2 replies
@loru88
Comment options

@acoulton
Comment options

Comment options

You must be logged in to vote
4 replies
@acoulton
Comment options

@loru88
Comment options

@loru88
Comment options

@acoulton
Comment options

Answer selected by loru88
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants