Automated module testing with CodeIgniter

Anyone who uses CodeIgniter uses automated module testing?

It seems that the guy CodeIgniter unit test should have a controller that runs in the browser,

eg.

However, I only want to test from the command line, I want automatic testing and assembly.

Any recommendation?

Thanks.

+8
php unit-testing codeigniter
source share
2 answers

You can use this integration with phpunit - http://www.foostack.com/foostack/

Then it will be launched from the command line.

+4
source share

That's what I'm doing:

  • Download Test.php
  • Create the 't' directory in the root of my CI application
  • Put Test.php in the t directory
  • Create a bootstrap.php file (see below) to initiate testing
  • require_once bootstrap.php file in my tests.
  • Run prove in the tests in the t directory

bootstrap.php :

 <?php // Initialize CodeIgniter, suppressing output. ob_start(); require_once __DIR__ . '/../index.php'; ob_end_clean(); require_once __DIR__ . '/Test.php'; 

Test example:

t/000-sanity.t :

 #!/usr/bin/env php <?php require_once 'bootstrap.php'; plan(1); is(true, true, 'Test.php works'); 

All CodeIgniter files available. For example, you can do $ci =& get_instance();

This setting works fine in CI 1.7.x and 2.x. Test.php is really easy to use.

+3
source share

All Articles