zt/unit-test

Thinkphp Unit Test

1.2 2016-12-26 10:09 UTC

This package is not auto-updated.

Last update: 2024-10-10 03:50:49 UTC


README

一个为ThinkPHP打造的的UnitTest,简单易用、高效便捷。


##How To Use

详细使用介绍查看项目example,下面列出一个简单的使用介绍

  • Application目录下创建Test/Controller,编写测试Controller。
  • 以编写 IndexController为例:
namespace \Test\Controller;
class IndexController extends UnitTest{
    
    /**
     *   调用方法:
     *   1. http://localhost/PROJECT_NAME/index.php?m=Test  自动执行全部测试文件
     *   2. http://localhost/PROJECT_NAME/index.php?m=Test&controller=XXX  自动执行参数crontroller指定的文件
     */
    function index(){
        $this->run(true); //测试方式1 : 通过自动遍历测试文件的方式执行测试
        
    }

    function index2(){
        $this->setController( array(__CLASS__ ,'\OtherClassName') );  //测试方式2 :设置将要执行的测试类
        $this->run();                               //执行测试代码

    }

    function testExample1(){                    //该方法将自动被测试
        $this->assertTrue(true);
        $this->assertFalse(false);
    }

    function testExample2(){                    //该方法将自动被测试
            $this->assertEmpty(null);
            $this->assertNotEmpty(true);
    }
}
  • 到浏览器运行 http://localhost/PROJECT_PATH/index.php?m=Test
  • 运行结果 IMG

##Bug && Contact Author