0

For 3 months, I've been working on a Web Project using PHP to create a platform to handle remote lights and sensors. I'm currently working almost alone on it, but we will be 2 on it in the next months.

As we are developping our business, we decided to try to work using an agile-like way of working. Nearly each month, we have a meeting with our client and I'm supposed to deliver a working version. But I realized I couldn't efficiently test my project because of many reasons:

  • I need to handle my 2 databases (the local one and the online one) and I can't put the local one online at each sprint because we have a big amount of online data that we don't want to delete.

  • It happens that PHP files aren't correctly transferred online, so some features are just partially added.

  • We still don't have different cases of use, creating bugs when new features are implemented and tested with other ones. I must test the plateform by myself and it's difficult to test it in an objective way.

So I was wondering if I should use PHP unit tests to help me handle part of the test work. As I'm mostly working on objects with add/update/save functions directly communicating with our MySQL DB, I don't know if this is relevant and/or necessary to use it.

Do you think I should take time to create a system of unit tests in this project or is that completely a waste of time? Do you have any other idea to help me to test my project? It seems to me that I would be losing so much time omplementing it and I don't even know if it's a relevant way of testing my project.

migrated from stackoverflow.com Jun 16 '17 at 9:44

This question came from our site for professional and enthusiast programmers.

2

I need to handle my 2 databases (the local one and the online one) and I can't put the local one online at each sprint because we have big amount of online data that we don't want to delete.

Sounds like you have two Environments - your Development box and the client's Live one. Not enough. You need [at least] one more for application testing, demonstrations and deployment testing.

it happens that php files aren't correctly transferred online, so some features are just partially added.

You absolutely must have reliable, resilient channels through which to deploy your application. Without these, releasing your hard work is reduced to pure guesswork.

we still don't have different cases of use, creating bugs when new features are implemented and tested with other ones. I must try the plateform by myself and it's difficult to test it in an objective way.

That's where your [separate] testing Environment comes in.

So I was wondering if I should use php unit tests to help me to handle part of the test work.

You should be considering just about anything that can help you filter out bugs before they hit your clients.

As I'm mostly working on objects with add/update/save functions directly communicating with our MYSQL DB, I don't know if this is relevant and/our necessary to use it.

Question: Does it matter if data gets correctly stored into your database? (Answer: Yes!)

If it does then you should have tests that prove that it does.

Do you think I should take time to create a system of unit tests in this project or is that completely a waste of time?

Do you have lots of problems where just changing code introduces new bugs? Testing would eliminate many of these.

Can you prove that your latest change hasn't affected any other part of the application? Testing can achieve this.

Notice that I didn't say "Unit Testing". There are many different levels of testing and you need to decide which is the most appropriate; Unit tests are, perhaps, the easiest to write and safeguard your code against "unexpected" changes but integration tests cover a much larger range of things, which might be more cost-efficient.

If you don't have any of these, start with Unit Tests and work up.

It seems to me that I would be loosing so much time to implement it ...

Testing does not prove the correctness of your code today.
You do that by writing the code to do what it needs to do and that's why it feels like "wasted" effort to do the job twice; once to code and again to write the tests.

Testing proves the continued correctness of your code over time. You will make changes to the code over the months and years that follow and your tests will ensure that you don't break anything (that you don't intend to).

  • Hi Phill, first, thanks a lot for taking time to answer my questions, much appreciated! It really helps me to feel more confident regarding to the different ways of testing my project. I'm going to look closer at integrations tests. I'm definitely convinced that I need to include it in my project in a near future. Thanks a lot again for your answer! – Victor Gerfaud Jun 16 '17 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.