PHPUnit只能从命令行运行。为什么? [英] PHPUnit runs only from the command line. Why?

查看:279
本文介绍了PHPUnit只能从命令行运行。为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:

<?php
    class MyTest extends PHPUnit_Framework_TestCase
    {
        public function testCalculate()
        {
            $this->assertEquals(2, 1 + 1);
        }
    }
?>

当我在浏览器中打开PHP文件时,会出现以下错误:

When I open the PHP file in the browser, I get the following error:

致命错误:找不到类'PHPUnit_Framework_TestCase'

Fatal error: Class 'PHPUnit_Framework_TestCase' not found

但是,如果我使用命令行,它工作正常:
phpunit [local_path_here] /testcase.php

However, if I use the command line it works fine: phpunit [local_path_here]/testcase.php

结果:

.

Time: 0 seconds, Memory: 5.00Mb

OK (1 test, 1 assertion)

为什么?

推荐答案

您可以集成插件运行单元测试通过本机网络GUI:

You can integrate add-on for running unit tests via native web GUI:

https://github.com/ NSinopoli / VisualPHPUnit

这篇关于PHPUnit只能从命令行运行。为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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