Welcome Guest, Not a member yet? Register   Sign In
Am I using Unit Testing Correctly?
#1

[eluser]Gram3000[/eluser]
Hello. I have been using Codeigniter for a couple of years and regretfully I am only now beginning to look at and learn unit testing.

I have begun using the Unit Testing Class and my first usage of unit testing was to create a controller which tested the output of each function in a particular model.

The model contains around 30 functions and as a result of the unit testing I believe I have improved the output of a few models. For example some models should have returned an array but if there was an error or a missing variable in the model then the model returned an integer or a string instead. I have updated the models to ensure their output is a consistent type.

My question is, is this the correct usage of unit testing? To test the output of functions? Is there more to it?

Thank you for any information or tips on using Uniting effectively.
#2

[eluser]vikascoollives[/eluser]
For me the unit testing is for the same you have mentioned .
It really helps to write a proper function .

If your each function is perfect then automatically your system performance will be good . That's what the unit test is for .
#3

[eluser]Gram3000[/eluser]
Hi Vikascoollives,

Thanks for your reply. Its good to hear how others use unit testing, I don't know any other developers that actively unit test.
#4

[eluser]SPeed_FANat1c[/eluser]
Hi, I am also new to unit testing and want to learn it. I tried the testing as written in documentation and it works ok. But still don't know how am I using it in practice.

Do we have to put testing functions in the same file? Lets say I create few models and then I have to put all testing functions for each model?

Ok, with models there is less problem - I can have one controller for testing and then load those models in it and test them all using one controller function.

But then what about controllers? I cannot have one controller where I could test all controllers, right? So I have to test each controller file seperately?

I assume testing is to about to make it all automatically so it should be somehow made that I run one function and it test the entire application.




Theme © iAndrew 2016 - Forum software by © MyBB