Reputation: 7451
Behat Api tests seem to be hitting the dev environment (dev cache folder is created, and it uses the dev database).
It creates the test database with no problems and adds the data (BeforeScenario method in FeatureContext).
My set up is as follows:
Have an app_test.php front controller.
default:
formatters:
pretty: true
autoload:
'': %paths.base%/app/features/bootstrap
suites:
app_suite:
type: symfony_bundle
bundle: AppBundle
contexts:
- AppBundle\Features\Context\FeatureContext:
parameters:
base_url: http://mysite.dev
mink_session: default
mink_javascript_session: selenium2
extensions:
Behat\Symfony2Extension: ~
Behat\MinkExtension:
sessions:
default:
symfony2: ~
This: http://www.forouzani.com/installing-behat-mink-and-selenium2-in-symfony2.html may have worked previously with behat 2, but I'm using behat 3 now so it doesn't seem to work as expected!
Thanks
Upvotes: 3
Views: 3802
Reputation: 12740
If you still cannot do after following steps below, I'll try to give you step by step example when I have time.
Update composer.json
"require": {
"php": ">=5.4",
"behat/behat": "3.0.14",
"behat/behat-bundle": "1.0.0",
"behat/symfony2-extension": "2.0.0",
"behat/mink": "1.6.0",
"behat/mink-extension": "2.0.1",
"behat/mink-browserkit-driver": "1.2.0",
"behat/mink-goutte-driver": "1.1.0",
"behat/mink-selenium2-driver": "1.2.0"
},
Run composer
php composer.phar update
Create behat.yml file.
default:
extensions:
Behat\Symfony2Extension: ~
Behat\MinkExtension:
base_url: http://behat-three.local/app_test.php
browser_name: firefox
sessions:
goutte: # fast, CLI, browser, no javascript support
goutte: ~
selenium2: # fast, CLI, opens up a browser
selenium2: ~
symfony2: # bleeding fast, CLI, no browser
symfony2: ~
suites:
test_suite:
type: symfony_bundle
bundle: SiteMainBundle
mink_session: selenium2
contexts:
- Site\MainBundle\Features\Context\FeatureContext:
output_path: build/behat/output
screen_shot_path: build/behat/screenshot
Initiate behat to create relevant files and fodlers to work with.
php bin/behat --init --suite=test_suite
Then make sure you have app_test.php
and update AppKernel
line.
# your_project/web/app_test.php
$kernel = new AppKernel('test', true);
Then create config_test.yml
with its own settings, something like.
# your_project/app/config/config_test.yml
imports:
- { resource: config_dev.yml }
framework:
test: ~
session:
storage_id: session.storage.mock_file
profiler:
collect: false
web_profiler:
toolbar: false
intercept_redirects: false
swiftmailer:
disable_delivery: true
doctrine:
dbal:
connections:
hello:
driver: pdo_sqlite
path: %kernel.cache_dir%/test_hello.db
Upvotes: 7