Skip to content
Advertisement

Tag: unit-testing

Should I be unit testing every piece of code

I have been starting unit testing recently and am wondering, should I be writing unit tests for 100% code coverage? This seems futile when I end up writing more unit testing code than production code. I am writing a PHP Codeigniter project and sometimes it seems I write so much code just to test one small function. For Example this

How to output in CLI during execution of PHP Unit tests?

When running a PHPUnit test, I would like to be able to dump output so I can debug one or two things. I have tried the following (similar to the PHPUnit Manual example); With the following result: Notice there is none of the expected output. I’m using the HEAD versions of the git repos as of September 19th, 2011. Output

PHPUnit: expects method meaning

When I create a new mock I need to call the expects method. What exactly it does? What about its arguments? I can’t find the reason anywhere (I’ve tried docs). I’ve read the sources but I can’t understand it. Answer expects() – Sets how many times you expect a method to be called: If you know, that method is called

Best practices to test protected methods with PHPUnit

I found the discussion on Do you test private method informative. I have decided, that in some classes, I want to have protected methods, but test them. Some of these methods are static and short. Because most of the public methods make use of them, I will probably be able to safely remove the tests later. But for starting with

Advertisement