Loading Please wait...

Unit Testing

Zigmoyd supports unit testing in simple way. By default your project is not prepared for unit testing you need to invoke codegen.unittest command to prepare your projectfor unit testing.

after that you can use assert Class to do unit Testing test cases. However you need to load unitTest module to do unit testing. even if you forget/dont load the unitTest module nither PHP nor zigmoyd will fire any error cause the then a dummy unitTest module will be used which have a dummy assert class that does nothing. e.g. use

class someController extends homeController{
  public function myMethod(){
    $this->load->module('unitTest');//Load the unit testign module
    $x = 2;
    assert::valid(($x == 2), "X is not equal to 2", __FILE__, __LINE__);
    $y = array();
    assert::strict((is_array($y)), "Y is not an array", __FILE__, __LINE__);
once you have ran your code with test cases (while unit testing is enabled) unit testing results of all tests have been logged into an INI file. that you can view with your favourate editor as well as with zigmoyd's unit test viewer.

when you just go to browser and visit http://localhost/zigmoyd/some/my to invoke the code no unit test result set will be genareted cause a page will be used for 1000 times a day so its not fair to generate a unit testing result sheet everytime.
So you need to enable unit testing by affixing a ?u GET variable at the end of the url to enable unit testing.e.g. http://localhost/zigmoyd/some/my?u when the ?u is given the unit test will be done else not.

However if you want (RECOMENDED) you can change the u to a different unit testing key. by changing the value of UNIT_GET_KEY in etc/unittest.ini.php file in your project's directory.

every unittest Session have an Test Id. if you just pass ?u the session ID of that Test session will be the Current timestamp. But if you Specify a custom session id as ?u=MYSESSIONIDNAME that test session will be named as MYSESSIONIDNAME

to view an unit testing result you need to go to the uSess method through your browser. e.g. as here the controller name is some you need to go to http://localhost/zigmoyd/some/uSess/MYSESSIONIDNAME e.g. pass the Session ID. if you havn't used any session ID use the timeStamp. However its always preferable to use a custom Session Id.

to protect your project from misuse you should change the value of UNIT_GET_KEY in etc/unittest.ini.php file in your project's directory as told above

Generated on Mon Oct 27 23:51:59 2008 for zigmoyd.kdevelop by doxygen 1.5.6