将PHPT测试用例与PHPUnit集成 [英] Integrate PHPT test cases with PHPUnit

查看:77
本文介绍了将PHPT测试用例与PHPUnit集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取PHPUnit以运行我的 PHPT测试用例并集成通过/失败状态进入整体指标?我已经知道如何使用 run-phpt 来运行这些测试>从命令行开始,但是我想在PHPUnit中与其他测试一起运行它们.

How can I get PHPUnit to run my PHPT test cases and integrate the pass/fail status into the overall metrics? I am already aware of how to run these tests using run-phpt from the command line, but I want to run them from within PHPUnit with my other tests.

我知道PHPUnit_Extensions_PhptTestCase存在,但是找不到有关如何使用它的示例.

I'm aware that the PHPUnit_Extensions_PhptTestCase exists but I couldn't find any samples on how to use it.

推荐答案

博客文章的要点关于测试文件上传的信息用于描述如何编写PHPT测试,并在文章末尾展示了如何将其集成到PHPUnit中.简而言之,您将.phpt文件的绝对路径传递给父构造函数.

While the main point of this blog post about testing file uploads is to describe how to write PHPT tests, it shows how to integrate them into PHPUnit at the end of the post. In short, you pass the absolute path to the .phpt file to the parent constructor.

<?php
require_once 'PHPUnit/Extensions/PhptTestCase.php';

class UploadExampleTest extends PHPUnit_Extensions_PhptTestCase {
    public function __construct() {
        parent::__construct(__DIR__ . '/upload-example.phpt');
    }
}

或者,您可以使用PHPUnit_Extensions_PhptTestSuite类,该类将目录作为其第一个构造函数参数,然后在该目录中搜索所有* .phpt文件.

Alternatively, you can use the PHPUnit_Extensions_PhptTestSuite class, that takes a directory as its first constructor argument and then searches for all *.phpt files within this directory.

这篇关于将PHPT测试用例与PHPUnit集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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