Framework tests and community help

Me was told, that Unit Tests to my framework would be no bad. I say it clear, that is quit hard to me, because this is very big Job. And I think, along I need 3 - 6 months for it. May be more…

Here is the link on test directory… https://github.com/igor1999/gi/tree/master/tests

If someone would to help me and write a couple of tests, I will be very grateful.

I should warn up front that testing after code has already been written tends to be a very painful task. Us developers don’t like pain, which is why writing the test first before doing the code is a much more successful technique.

There are two main loops involved when using tests. A main loop where you write a failing test that specifies the desired new behaviour, write the minimal code to make the test pass, then refactor. That’s the big loop, which you’ll hear about as being the red-green-refactor loop.

Refactoring the code is the second more internal loop that occurs. While keeping the tests green and passing, you rework the code without changing its interface so that you are happier about how it works.

The benefit of the first part is that it gives you a really nice way to think about the structure of your code, and the benefit of the second part is that you get to make big improvements to how your code works, with a battery of tests standing ready to help inform you if you break something.

When dealing with code that doesn’t have any tests, I try to recommend that you use tests for every change that you make to the code from now on. That helps to inform you about where changes occur to your code, and the tests can then be filled out in those areas to give you better coverage.

Speaking of coverage there are also coverage tools available (I’m not sure what are decent ones for PHP, someone please advise) that help to inform you about code that is not yet supported by any tests.

Having said all that, my place is with JavaScript and not PHP, so I invite others here that are more involved with PHP to provide more input about testing, and things that can help with it comes to starting off with a large set of untested code.

As a starting off point, the following article gives you step by step examples of testing PHP code for a simple app.

And, the following book on PHP testing helps to give further details too.

http://www.kamibarut.de/pdf/practical-php-testing.pdf

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.