[eluser]Unknown[/eluser]
Hi, I am really interested about how unit test works in codeigniter. I have created a very basic controller with the following example. I just point to the function where I am about to do the testing. How should i display the result? I tried pointing to another function to show result but it doesn't seem to give any respond.
Can anyone briefly explained to me how it works?
Code:
<?php
class User extends Controller{
function User(){
parent::Controller();
$this->view_data['base_url'] = base_url();
}
function index(){
$this->addition();
}
function addition()
{
$this->load->library('unit_test');
$test = 1 + 1;
$expected_result = 2;
$test_name = 'Adds one plus one';
$this->unit->run($test, $expected_result, $test_name);
$this->showresult();
}
function showresult()
{
$this->load->library('unit_test');
$str = '
<table border="0" cellpadding="4" cellspacing="1">
{rows}
<tr>
<td>{item}</td>
<td>{result}</td>
</tr>
{/rows}
</table>';
echo $this->unit->set_template($str);
}
}