1

When I want run my behat test like in this tutorial, I get an error message:

➜  test.dev bin/behat --suite=system
PHP Fatal error:  Cannot redeclare class SystemContext in /Applications/MAMP/htdocs/test.dev/features/bootstrap/SystemContex.php on line 12

And I do not know why, because I wrote my behat.yml like at this page:

default:
    suites:
        site:
            paths: [ %paths.base%/features/site ]
            contexts: [ SiteContext ]
        system:
            paths: [ %paths.base%/features/system ]
            contexts: [ SystemContex ]
extensions:
    MageTest\MagentoExtension\Extension: ~
    Behat\MinkExtension:
        base_url: 'http://test.dev/'
        selenium2:
            wd_host: http://127.0.0.1:4444/wd/hub
            browser: firefox

My file structure is like:

project-dir
├── behat.yml
├── bin
│   └── behat
├── composer.json
├── composer.lock
├── features
│   ├── bootstrap
│   │   ├── FeatureContext.php
│   │   ├── SiteContext.php
│   │   └── SystemContext.php
│   ├── site
│   │   └── ...
│   └── system
│       └── check_baseurl.feature
├── htdocs
│   ├── app
│   ├── downloader
│   ├── index.php
│   ├── js
│   ├── skin
│   ├── var
│   └── ...
└── vendor
    ├── autoload.php
    ├── behat
    ├── magetest
    └── ...
0

1 Answer 1

1

Important: several problems occur because you copy and paste behat.yml from website to your behat.yml - there are sometimes whitespaces, that you can't see but will effect your behat system!!!

You should re-write the behat.yml, the context mentioned in behat.yml is wrong. It should be as follow.

default:

suites:

default:

paths:

features: features/site

contexts:

- SiteContext

system:

paths:
 [ %paths.base%/features/system ] contexts:
 [ SystemContext
 ]

By default context is searched in bootstrap folder, you just have to mention the filename of the context file.

And to execute the suite execute the following command

bin/behat --suite=system

Note: use bin/behat in command if you are executing suite from project root directory. If you are in bin folder just use behat before execution

3
  • @Jurik I have updated the answer, your system suite should be aligned with default, and command for executing is different as I have mentioned it in answer Commented Feb 24, 2016 at 11:19
  • Thanks, but I figured out that everything is good in my behat.yml - my problem was that I copy & pasted from a website. This caused some whitespace issues. My config is just like in the behat docs.
    – Jurik
    Commented Feb 24, 2016 at 11:19
  • Ahhh... yml files sucks.. faced same issues before anyways good luck Commented Feb 24, 2016 at 11:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.