CodeIgniter and SimpleTest — How to make my first test?

半城伤御伤魂 提交于 2019-12-04 14:49:30

Edit:

If you are following the maroonbytes setup, just follow the instructions:

  1. Download the SimpleTest framework and extract the files into your @codeigniter directory.
  2. In both your main folder and your admin/application folder create a new folder called tests.
  3. Within the new tests folder setup additional folders called ‘models’, ‘views’, ‘controllers’, ‘libraries’ and ‘helpers’.

Any file ending in .php and with a UnitTestCase inside any of those folders, should be run. :)

Smandoli

First, tests must be named properly. To test a controller welcome placed in the file welcome.php a test is named welcome_controller_test.php and stored under tests/controllers/. For more, see this post.

Second, Xdebug's GET argument interferes with the test routine. See post just above, also this post.

Third, the stub test I posted needed two four lines deleted:

//require_once('../simpletest/unit_tester.php');
//require_once('../simpletest/reporter.php');
...
//$test = new TestOfMysqlTransaction();
//$test->run(new HtmlReporter())

I am making tests fairly happily now. CodeIgniter lets me create/maintain tests easily, so my goal of TDD looks reachable. My earlier attempts at TDD gave me the idea, but scratch PHP was just too barren for me to be effective (and we won't discuss VBA!).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!