Behat Tests #948

Closed
wants to merge 9 commits into
from

Conversation

Projects
None yet
2 participants
Owner

chillu commented Nov 13, 2012

Migrated from https://github.com/silverstripe-labs/SilverStripe-Behaviour-Testing-Framework, which is now an obsolete repo (will delete once this is merged). I've split out the 'cms' specific tests in a separate commit, see silverstripe/silverstripe-cms#236

The majority of docs is placed in the generic SS Behat extension: https://github.com/silverstripe-labs/silverstripe-behat-extension

In general, there's two main areas where I'd like to improve the workflow:

Once we merge back Andrew's changes around module paths, we can also implement a cleaner autoloading process, rather than the forced composer partial autoloading at the moment.

@sminnee sminnee commented on an outdated diff Nov 14, 2012

tests/behat/behat.yml
@@ -0,0 +1,35 @@
+default:
+ context:
+ class: SilverStripe\Test\Behaviour\FeatureContext
+ extensions:
+ SilverStripe\BehatExtension\Extension:
+ framework_path: ../../
+ Behat\MinkExtension\Extension:
+ # Adjust this to your local environment
+ base_url: http://localhost/
@sminnee

sminnee Nov 14, 2012

Owner

We can't really have the base_url hardcoded here. :-( Do we need to have a phing task that generates the behat.yml based on SilverStripe's knowledge of its environment?

Owner

sminnee commented Nov 15, 2012

Given that the base_url can be overridden with environment variables, I think this is good to merge.

Owner

sminnee commented Nov 15, 2012

Behat, however, needs to be excluded from the PHP_CodeSniffer check. It's failing travis with a long line.

Update: Wait, no, it's just that /behat/features/bootstrap/SilverStripe/Test/Behaviour/CmsUiContext.php needs to have its line shortened.

Owner

chillu commented Nov 15, 2012

Hold off on the merge please, I've got a bunch of local changes, which were necessary due to some behat.yml restructuring in the silverstripe-installer project (related to our discussion there)

Owner

chillu commented Nov 15, 2012

@sminnee I've added a behat.yml to the base folder, and removed the module specific ones.
Behat has a "context class guesser" which I've implemented for SilverStripe, so you can run tests for a module with a specific FeatureContext through vendor/bin/behat @<module-name>.

The default behat.yml is much slimmer now, since I've moved more config stuff to defaults (quite a mission to find out how all the DI/config pieces fit together in Symfony2, but very interesting). base_url is now commented out in behat.yml, so by default you get a meaningful error message. You can fix this either through environment vars, or by customizing the file. For the TeamCity builds I've chosen the latter, since we need other adjustments such as the SauceLabs credentials anyway.

I've switched the TeamCity builds to use composer. It slows down the checkouts since they have to be on the agent rather than the server, and can't benefit from the built-in TeamCity optimizations (transferring pre-checked-out repos).
Necessary evil from what I can tell. The build stops at "target 'behat' not found" at the moment, further testing after these changes are merged.

Going forward, I want to simplify behat test inititialization for new modules,
see silverstripe-labs/silverstripe-behat-extension#1.
That should make adoption a bit easier. Its still a bit weird to operate with these
"partially namespaced" modules, will be clearer once most modules are namespaced by default.

Fixed the codesniffer checks (just hadn't pushed),

Owner

sminnee commented Nov 15, 2012

Alright, that all sounds good. I won't be able to merge until our afternoon (meetings all day) but will look again in the afternoon.

Owner

sminnee commented Nov 16, 2012

Squashed the cleanup for the step wording and behat.yml into the initial commit (since it appeared to be related to you changing your mind) and merged.

sminnee closed this Nov 16, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment