2012-03-27 55 views
1

我有以下情形的:贝哈特步骤定义有时执行有时不

@wip 
Scenario: Attempt to get account information of an activator without credentials 
Given an activator with e-mail "[email protected]" and password "testpassword" already exists 
When I send a GET request to "/activators/1" 
Then the response code should be 401 

@wip 
Scenario: Attempt to get account information of another activator then myself 
Given an activator with e-mail "[email protected]" and password "testpassword" already exists 
And an activator with e-mail "[email protected]" and password "testpassword" already exists 
And I am authenticating as "[email protected]" with "testpassword" password 
When I send a GET request to "/activators/1" 
Then the response code should be 401 

数据库每隔方案之前下降,从架构重新创建。

步骤'给予激活器...'将新用户插入到数据库中。
但是!它并不总是为两个用户做到这一点。

这是分步实施:

/** 
* @Given /^an activator with e-mail "([^"]*)" and password "([^"]*)" already exists$/ 
*/ 
public function anActivatorWithEMailAndPasswordAlreadyExists($email, $password) 
{ 
    $activatorManager = $this->getContainer()->get('am.manager.activator'); 
    #$logger = $this->getContainer()->get('logger'); 
    #$logger->debug("Email: $email, password: $password"); 
    $activator = $activatorManager->createActivator($email, $password); 
    $activatorManager->save($activator); 
} 

现在奇怪的事情:
在这最后一步,我应该得到两个插件:一个用于dietervds,eviltwin之一。

我得到了两个插件,当我:

  • 只运行一个场景
  • 输出的东西在日志(创建“记录仪”没有帮助,我需要输出的东西我没有按输出。 “T必须是动态的,它可以只是一个固定的字符串)

我只得到一个接插件(适用于dietervds)当我:

  • 运行两个方案一起
  • 或当我在步实施

不输出任何记录,我完全被这个困惑。
有没有明显的缺失?可能是步骤定义中的某种缓存问题? (日志可能会更改签名什么的,不知道)

欢迎任何的反馈:-)

干杯!

Dieter

回答

1

这一步def做ajax调用吗?

当我发送一个GET请求到“/激活/ 1”

如果这样做,你可以尝试加入一些等待时间在那里给你的DOM的时间来加载结果

当你用press或跟随链接提交表单或者去重定向浏览器时,Thens的工作效果最好,该浏览器启动一个完整的请求响应循环,触发机器人等待新的dom加载。

与ajax不完全相同的方式发生。

如果你不这样做的AJAX,我建议你只使用内置的

When I follow "/activators/1" instead 

一步DEFS有一种方法,以防止缓存在YAML配置。下面是我们使用的镀铬为例配置,但它应该工作相同的任何浏览器驱动器

default: 
    extensions: 
     Behat\MinkExtension\Extension: 
      base_url: https://yurwebsite.com 
      goutte: ~    
      browser_name: "googlechrome" 
      selenium2: 
       capabilities: { "browser": "googlechrome", "version": "23", "applicationCacheEnabled": false } 

最后布尔PARAM确实为我们的浏览器缓存的伎俩发出

+0

感谢您的答复mugafuga! 我很确定它没有实际执行AJAX调用。但不幸的是,我再也不能检查了。也许你的回答会帮助一个有类似问题的人。 – Dieter 2013-01-11 11:17:50