加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – 如何在测试开始时避免额外的HTTP请求?

发布时间:2020-12-13 16:20:07 所属栏目:PHP教程 来源:网络整理
导读:假设我有这样的测试: class SortTest extends PHPUnit_Extensions_Selenium2TestCase{ public function setUp() { $this-setHost('192.168.1.1'); $this-setBrowserUrl('http://some.url/'); $this-setBrowser('chrome'); } public function testFoo() { $t
假设我有这样的测试:

class SortTest extends PHPUnit_Extensions_Selenium2TestCase
{
    public function setUp()
    {
        $this->setHost('192.168.1.1');
        $this->setBrowserUrl('http://some.url/');
        $this->setBrowser('chrome');
    }

    public function testFoo()
    {
        $this->url('/foo');
    }

    public function testBar()
    {
        $this->url('/bar');
    }
}

如果我运行此测试,我将看到每次加载根页面,然后打开所需的/ foo或/ bar.

如果我注释掉或移动setBrowserUrl()调用测试方法 – 我得到Undefined索引:browserUrl

那么有没有办法避免测试方法设置上的冗余HTTP请求?

解决方法

So is there a way to avoid that redundant HTTP request on test method set up

通过将浏览器URL设置为空字符串$this-> setBrowserUrl(”);但是它要求每个其他网址都是绝对的$this-> url(‘http://some.url/foo’);这不会阻止selenium尝试访问空网址,但会更快,特别是如果起始网页很重

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读