Open jnicola opened 1 year ago
...also I know I can just have different environments / jenkins jobs exclude certain tags etc etc. I'm really not looking to solve this with tag exclusion, if possible.
Just add this to a context...
/**
* @BeforeScenario
*/
public function beforeScenario(BeforeScenarioScope $scope)
{
$tags = array_merge($scope->getScenario()->getTags(), $scope->getFeature()->getTags());
if (in_array('requiresInitialImport', $tags, true) && !$this->databaseIsImported()) {
throw new PendingException('required initial import');
}
}
Just add this to a context...
/** * @BeforeScenario */ public function beforeScenario(BeforeScenarioScope $scope) { $tags = array_merge($scope->getScenario()->getTags(), $scope->getFeature()->getTags()); if (in_array('requiresInitialImport', $tags, true) && !$this->databaseIsImported()) { throw new PendingException('required initial import'); } }
Thanks. This worked for me when developing locally, however not for CI: Reason is that exit code is set to 1 (failed), whenever an exception is thrown during setup hooks.
Anyone has an idea on how to tweak exit code?
how about https://github.com/tkotosz/behat-skip-tests/ ?
I'd like to be able to skip a scenario entirely based on some conditional checks in a @BeforeScenario.
For some of our test environments, we don't fully import the default content since it would bog down testing.
However, I want to be able to setup nightly test runs that do have the default content brought in.
Tests marked with a tag such as
requiresInitialImport
would check against the database to see if an import has been performed. If it hasn't, skip the test it's okay. If it has however had imports performed, it's fair game!