2012-07-24 131 views
0

在发布之前,我在这个网站和谷歌上查了很多,想清楚我的问题。 我正在测试我的web应用程序,该应用程序主要使用Symfony2框架以PHP编码。Selenium-PHPUnit,Selenium Grid

我正在使用硒做我的功能测试。我现在想要做的就是使用Selenium Grid在本地机器上并行运行我的功能测试。我所做的是在Selenium IDE上记录测试,并以phpunit格式导出测试用例。我试图使用硒网格,但我的phpunit测试仍然按顺序运行。

我所做的:

1)Java的罐子硒的服务器独立-2.24.1.jar -role枢纽

2) java -jar selenium-server-standalone-2.24.1.jar -role node -hub http://localhost:4444/grid/register -browser "browserName=firefox,maxInstances=2,maxSession=2" 

3)蚂蚁

有一个在我的构建.XML一个目标的PHPUnit:

<target name="phpunit" description="Run unit tests"> 
    <exec executable="phpunit" failonerror="true"/> 
</target> 

以我phpunit.xml这部分代码是本:

<testsuites> 
    <testsuite name="LoginSuite"> 
     <file suffix="Test.php">../../src/Tests/FunctionalTests/LoginSuite_testLoginTest.php</file> 
    </testsuite> 
</testsuites> 

而且我LoginSuite_testLoginTest.php看起来是这样的:

<?php 

namespace Tests\FunctionalTests; 
use Tests\FunctionalTests\SetUpTest; 

class LoginSuite_testLoginTest extends SetUpTest 
{ 
    public function testLogin() 
    { 
    $this->open("/home"); 
    $this->click("link=Login"); 
    $this->type("id=username", "[email protected]"); 
    $this->type("id=password", "test"); 
    $this->click("id=_submit"); 
    $this->waitForPageToLoad("30000"); 
    } 


    public function testLogin2() 
    { 
    $this->open("/home"); 
    $this->click("link=Login"); 
    $this->type("id=username", "[email protected]"); 
    $this->type("id=password", "test"); 
    $this->click("id=_submit"); 
    $this->waitForPageToLoad("30000"); 
    } 
} 
?> 

在第三步中,当我启动ant命令我得到一个错误码头500问题访问/硒服务器/驱动器/

如果而不做:

java -jar selenium-server-standalone-2.24.1.jar -role node -hub http://localhost:4444 /grid/register -browser "browserName=firefox,maxInstances=2,maxSession=2" 

我不-browser信息相同的命令它启动我的测试但并不平行......,这很奇怪。

我看到要并行启动phpunit测试,我们必须创建自己的脚本来完成它。所以在这种情况下,我需要硒电网吗?我很困扰。谢谢你的帮助。

回答

0

phpunit命令行https://github.com/siivonen/parallel-phpunit有一个并行包装,因此您不需要编写它。你需要在某处运行Selenium Hub(连接一些节点)。然后,您运行指向该位置的测试,Hub将代理到空闲节点的呼叫。

我们使用parallel-phpunit和Selenium Grid,并将四个节点连接到集线器。我们的CI在3分钟内运行30分钟的硒测试。

0

可能有不同的问题。一种是,在运行预先记录的步骤时,应该在“浏览器”参数中添加seleniumProtocol = Selenium,因为默认情况下它将是webdriver。