how to let behat know which context to use?, because by default,there is this FeatureContext.php inside the features folder, whereby, when the behat runs, it will use that file while the .feature file is running (scenarios)...the problem is, if I have alot of modules to test, ofcourse, I cannot just lump all of those functions inside one FeatureContext.php file right?, I would want to name different contexes and different .feature files, so how to let behat know which context and .feature file to run?
this is the line of command that i use to fire behat
/export/home/project/htdocs/bdd/bin/behat --profile phantomjs-via-webdriver
Behat uses all of the contexts you specify, the only way out of this is to specify only the context(s) you want to use. Depending on the Behat version the syntax also differs. For Behat 2 this answer explains one strategy. For Behat 3 you can do the following:
default:
suites:
module1:
contexts:
- 'FeatureContext1'
- 'FeatureContext2'
module2:
contexts:
- 'FeatureContext1'
- 'FeatureContext3'
My two cents: I don't have a tiniest idea about your app, but don't confuse functional and unit testing (if you do). There can be different situations when you benefit from per module contexts, like "authorisation", "admin", or "comments", but their only purpose is to separate code from the overall context into a more manageable chunks. They still work together and cover the entire application (or a very distinct part of it). Testing module-specific functionality would be a lot easier with a unit test framework, which ensures that the modules works on their own.