Technology

On the path to testing

Posted by Pixafy Team

On the path to bug testing  |  Pixafy.com

Over the past few months, I’ve experienced the horror of fixing bugs or implementing enhancements only to come back later and find that another section of the application broke. I wanted to minimize these bugs, so I decided to start getting into unit testing.

I’ve found that there are two types of testing that can be useful for my web development: unit testing and functional testing. In unit testing, you test the code to see that the code is working properly and performing the tasks correctly. In functional testing, you test the application to check if it’s using and calling the code correctly. That is, unit tests are used from a developer’s perspective and functional tests are used from a user’s perspective. It’s a subtle but very important difference.

Both unit testing and functional testing are important, so I’ve been trying to implement both into project I’m currently working on. However, I’ve had some troubles with it.

One of the biggest difficulties I’ve had is simply just managing the tests. The problem is that when I write a test for a certain component, I would need to update it every time someone made any changes related to it, including both code changes and database changes. On the functional side, it’s even harder because the client and design company are constantly changing their requirements. Or worse, they never even thought of the scenario in the first place. All of these small things add up into many, many possible test cases that require significant time to maintain.

Unfortunately, you don’t often have significant time to maintain such tests. Many projects have aggressive and strict deadlines, so you need to spend more time doing actual development rather than maintaining tests.

Another difficulty I’ve had is coming up with the tests. Because I’m just starting out, I’m not exactly sure what the best test cases are. I don’t know what I should be testing or how thorough I should be. The web application I’m working on is huge, so I don’t know what’s considered trivial or what’s important. I don’t know what can be tested quickly or what should be tested extensively. I assume this is something that I’ll gain through more experience, so I’ll be continuing adding tests. I hope that when we reach beta and start receiving bug reports, I’ll be able to get a better sense of how to structure my tests to that I can minimize the amount of bugs in future projects.

Even with these difficulties, I’m sure that testing will help out in the long run. Over time, the amount of time spent on getting these tests to work properly will surely minimize the amount of time needed to fix bugs in future development.

In my next post, I’ll be explaining how I set up PHPUnit  (https://github.com/sebastianbergmann/phpunit/) in conjunction with Codeigniter and PHPStorm on my Windows-based computer.

Questions or comments? Share them below, or tweet us @Pixafy!