PHPUnit如何通过注解生成测试类

WBOY
Release: 2016-06-06 20:23:09
Original
1375 people have browsed it

我在《PHP核心技术与最佳实践》(列旭松 陈文 著)中的第12章节中了解到PHPUnit可以通过注解生成测试类:

<code>class Calculator
{
    /**
     * @assert (0, 0) == 0
     * @assert (0, 1) == 1
     * @assert (1, 0) == 1
     * @assert (1, 1) == 2
     * @assert (1, 1) == 3
     */
    public function add($a, $b){
        return $a + $b;
    }

    public function add2($a, $b){
        return $a + $b;
    }

}</code>
Copy after login
Copy after login

以上代码会生成五个assert断言,但是书中是使用NetBean,我手头条件限制无法复现,请问如何通过命令完成以上需求?(PHPUnit stable v5.0)

回复内容:

我在《PHP核心技术与最佳实践》(列旭松 陈文 著)中的第12章节中了解到PHPUnit可以通过注解生成测试类:

<code>class Calculator
{
    /**
     * @assert (0, 0) == 0
     * @assert (0, 1) == 1
     * @assert (1, 0) == 1
     * @assert (1, 1) == 2
     * @assert (1, 1) == 3
     */
    public function add($a, $b){
        return $a + $b;
    }

    public function add2($a, $b){
        return $a + $b;
    }

}</code>
Copy after login
Copy after login

以上代码会生成五个assert断言,但是书中是使用NetBean,我手头条件限制无法复现,请问如何通过命令完成以上需求?(PHPUnit stable v5.0)

原来是一个生成骨架来的:第 13 章 骨架(Skeleton)生成器

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template