如何在PHPUnit + Selenium中运行测试? [英] How to run a test in PHPUnit+Selenium?

查看:98
本文介绍了如何在PHPUnit + Selenium中运行测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了所有东西,并且可以在项目菜单中右键单击测试,然后选择运行",从而在NetBeans中很好地创建和运行测试.问题是为测试打开的浏览器窗口在运行测试后立即关闭-这意味着我仅有的报告是NetBeans提供的,这还不够.我不想使用命令行,而且过去无论如何我都没有取得太大的成功.

I have everything installed and I am able to create and run tests in NetBeans fine by right clicking the test in the project menu and selecting "Run". The problem is that the browser windows opened for the test close immediately after the test is ran - meaning that the only reporting I have is what NetBeans provides and that's not enough. I don't think I want to use the command line, plus I haven't had much success with it in the past anyways.

是否可以仅将浏览器指向test.php文件?当我尝试执行此操作时,出现此错误:

Is it possible to just point the browser at the test.php file? When i try to do that I get this error:

致命错误:在第275行的C:\ xampp \ php \ PEAR \ PHPUnit \ Extensions \ SeleniumTestCase.php中找不到类'PHPUnit_Framework_TestCase'

Fatal error: Class 'PHPUnit_Framework_TestCase' not found in C:\xampp\php\PEAR\PHPUnit\Extensions\SeleniumTestCase.php on line 275

我不能从其他计算机上执行这些测试吗?即PC1是我专用的硒测试盒,我想告诉它从PC2远程运行test.php.

Shouldn't i be able to execute these test from a different machine? ie PC1 is my dedicated selenium test box and I want to tell it to run test.php from PC2 remotely.

我的测试文件应该放在哪里?

Where should my test files go?

如何自定义测试脚本中的报告/输出?

How do I customize the reporting/out put from the test script?

推荐答案

我发现了如何远程运行测试文件的方法-我刚刚创建了一个脚本,该脚本将从命令行执行phpunit:

I found out how to run my test files remotely - i just created a script that would execute phpunit from the command line:

<?php
exec('c:\xampp\php\phpunit.bat c:\xampp\htdocs\selenium\testcases\newSeleneseTest.php', $output);
    echo "<pre>".  var_export($output,TRUE)."</pre>";
    exec('c:\xampp\php\phpunit.bat c:\xampp\htdocs\selenium\testcases\newSeleneseTest.php', $output);
    echo "<pre>".  var_export($output,TRUE)."</pre>";
    ?>

然后我只需点击该脚本的URL即可运行-效果很好,但我仍然认为应该有一种更好/更简便的方法...

then I can just hit the URL of that script to have it run - works great, but I still think there should be a better/easier way...

这篇关于如何在PHPUnit + Selenium中运行测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆