Welcome Guest, Not a member yet? Register   Sign In
is there any testing framework for CI?
#1

[eluser]gluis[/eluser]
hi ci hackers,

i come from a world where test:code coverage is pretty important for applications (especially for client apps), and i can't seem to find any mention of functional testing for ci. the user's guide has some example unit testing samples, but i'm looking for more extensive tools.

what am i missing? where's a good place to find this info?

thanks!

gluis
#2

[eluser]frietkot[/eluser]
Have you tried the unit test library?
http://ellislab.com/codeigniter/user-gui...sting.html
#3

[eluser]gluis[/eluser]
thanks, frietkot. i did see that (i mentioned it in my post). but i was looking for a bit more than that--though that's still not bad. ;-)
#4

[eluser]gluis[/eluser]
no, i haven't. i just started playing around w/ CI. i looked at it months ago, but never did anything. now i'm starting to learn it just in case i need to build something for an EE build early next year (assuming EE 2 is out). but i'll definitely look into it. thanks for the tip! (any bit of info helps me assemble a little testing environment to do TDD if i can)
;-)
#5

[eluser]JensRoland[/eluser]
You may want to check out my new JUnit-like unit testing suite, Toast:

Features:

* lightweight and unobtrusive - the entire suite has just 2 code files, and one of them is optional ;-)

* works with CI with no changes - just drop it in and it works

* simple JUnit-style syntax

* works entirely in the browser - no need for shell access

* run single tests, sets of tests, or all tests at once (all in the browser)

* auto-benchmarking using CI’s benchmarking class


An example of the way you write tests in Toast:

Code:
require_once(APPPATH . '/controllers/test/Toast.php');

class My_test_class extends Toast
{

    function My_test_class()
    {
        parent::Toast(__FILE__); // Remember this
    }

    function test_some_action()
    {
        // Test code goes here
        $my_var = 2 + 2;
        $this->_assert_equals($my_var, 4);
    }

    function test_some_other_action()
    {
        // Test code goes here
        $my_var = true;
        $this->_assert_false($my_var);
    }

}

Anyway, I’ve put the source code up for download from my site, along with a simple user guide.

Toast v1.1 - Unit Testing suite for CodeIgniter

I’m hoping it'll make it a little bit easier for people to do proper Test-Driven Development in CodeIgniter.


All the best-

/Jens Roland
#6

[eluser]onblur[/eluser]
UPDATE: Scrub that - forgot to set base url in config. :roll: Is working perfectly!!!

Hi Jens, thanks for contributing your TOAST unit testing suite. I've been trying it out. Works great for me when running test classes or individual test methods e.g.

Code:
http://localhost/index.php/test/example_tests
http://localhost/index.php/test/example_tests/simple_addition

These work fine. But if I run toast_all I get errors.

Code:
http://localhost/index.php/test/toast_all

outputs...

Code:
Toast Unit Tests:

Not Found
The requested URL /index.php/test/example_tests/show_results was not found on this server.
Apache/2.2.3 (CentOS) Server at example.com Port 80

Not Found
The requested URL /index.php/test/greg_tests/show_results was not found on this server.
Apache/2.2.3 (CentOS) Server at example.com Port 80


All tests completed in 0.7387 seconds
#7

[eluser]salbertson[/eluser]
I am running into this same problem. Did you ever figure out what was wrong?
#8

[eluser]onblur[/eluser]
Has been a while since this - I can't recall exactly the details. From memory, it was working fine for me. My reference to the base_url in the config probably refers to settings in the testing framework rather than CI. Sorry can't be more specific - memory fails me.
#9

[eluser]salbertson[/eluser]
Thanks, I figured it out. It was a combination of the base_url in config and the router was looking for toast_all.php in lowercase, not Toast_all.php that comes with the library. Simple fix and now it works great.




Theme © iAndrew 2016 - Forum software by © MyBB