php CI框架单元测试
来源:互联网 发布:淘宝官方客服电话95188 编辑:程序博客网 时间:2024/05/16 06:09
这两天在做一个网站的东西,对外提供系统API,为了测试这些接口,看了一下CI框架的单元测试,下面直接上代码:
<?phpclass apitestLogin extends CI_Controller {var$sessionkey="获取到的sessionkey";var $basePath ="http://**/index.php?";function __construct(){parent::__construct ();$this->load->Model ( 'common' );$this->load->Model('logintestModel','login');$this->load->library('unit_test');//首先load library unit_test;}function index(){$test = $this->login->testLogin();//被测试的方法testLogin(),方法的返回值 $test $expected_result ='{"flag":1,"msg":"success","sessionkey":"e206c4856a06130110b95ed7c8c473e2"}';//期望的返回值$test_name = 'test login()';//给当前的测试起个昵称 起个小名 起个乳名......$this->unit->run($test, $expected_result, $test_name);//密码错误$test = $this->login->testLogin1();$expected_result =-2;$test_name = 'test login';$this->unit->run($test, $expected_result, $test_name);$test = $this->login->testLogin2();$expected_result ='{"flag":-5,"msg":"JSON format is not correct"}';$test_name = 'test login';$this->unit->run($test, $expected_result, $test_name);$test = $this->login->testLogin3();$expected_result ='{"flag":-5,"msg":"JSON format is not correct"}';$test_name = 'test login';$this->unit->run($test, $expected_result, $test_name);$test = $this->login->testLogin4();$expected_result ='{"flag":-5,"msg":"JSON format is not correct"}';$test_name = 'test login';$this->unit->run($test, $expected_result, $test_name);//print_r( $this->unit->result());//数组的形式返回测试结果echo $this->unit->report();//报表的形式返回测试结果}}?>
- php CI框架单元测试
- PHP CI 框架
- php CI框架入门
- CodeIgniter框架 CI PHP
- PHP CI框架配置
- PHP验证码-CI框架
- php ci框架之配置
- php ci框架之controller
- php ci框架之view
- php CI框架连SQLServer
- CI框架去除index.php
- php CI框架搭建(一)
- php CI框架搭建(二)
- php CI框架搭建(三)
- PHP框架之CI:CodeIgniter
- php ci框架 页面缓存
- ci框架&tp框架隐藏index.php
- 去掉 CI 框架中的 index.php
- 在Android中使用WindowManager实现悬浮窗口
- css控制文章段落文字两端对齐
- 支持源文件索引符号服务器的构建和使用
- android弹出activity设置大小
- Bean(应用组件)在Spring容器中的生命周期
- php CI框架单元测试
- 网站页面IE兼容性问题(初涉)
- Two.js —— 二维的绘图 JavaScript 库
- Oracle树形查询
- Android View.post(Runnable )
- 阿里巴巴笔试题 (2011年度)
- final 修饰符
- windows下网络操作
- ibatis学习(一)--ibatis介绍以及用例