MageTest / BehatMage

Behat for Magento
MIT License
85 stars 31 forks source link

Basic steps do not work #67

Closed ScreamingDev closed 9 years ago

ScreamingDev commented 9 years ago

The simple steps like "I should see" etc. do not work Running behat as described in the README.md it fails to do this:

Scenario: Display Header
    Given I log in as admin user "admin" identified by "123123pass"
     When I open admin URI "/admin/process/list"
     Then I should see text "Index Management"

In a dry-run it tells me to create the step:

You can implement step definitions for undefined steps with these snippets:

    /**
     * @Then /^I should see text$/
     */
    public function iShouldSeeText()
    {
        throw new PendingException();
    }
debo commented 9 years ago

Hi @sourcerer-mike that's correct. BehatMage is not aware of your domain so any step specifically defined outside of Behat or BehatMage. So in your specific case you should write the step definition code in a way that is going to look similar to the following:

<?php
/**
 * @Then /^I should see text "([^"]+)"$/
 */
function iShouldSeeText($text) {
    assertNotNull($this->find('xpath', '//h1[contains(., "'.$text.'")]'), "Text '$text' was not found on the page");
}

Please let me know if that helps

ScreamingDev commented 9 years ago

Well it either should have some or should be compatible with others so that it can go hand in hand with a subcontext.

debo commented 9 years ago

@sourcerer-mike I'm not sure I'm following. There are certain steps that obviously are present already, pretty much all those available in standard Behat. But anything that is out of the known domain it can't be present, for instance what if you say

I should see text "text value"

And someone else says

I should see "text value"

we can't clearly support both

ScreamingDev commented 9 years ago

That might be. So it's the other way: compatibility with other contexts. As I added Mink as subcontext behat argues about duplicates.

Try this:

$this->useContext('subcontext_alias', new MinkContext());
debo commented 9 years ago

Well the reason is that BehatContext extends RawMinkContext so it already inherits all the steps and methods that mink provides. As I said I am a bit confused about what's the problem is, if it's the lack of built-in steps, which is something we are woking on, or something else.