Jump to content

testing and version control advice


dadamssg87

Recommended Posts

To preface: I'm the only person working on my project and am using the CodeIgniter framework, MAMP, and TextMate on my macbook pro. I'm developing a web shopping cart integrated with Authorize.net. I will be selling this and am intending to make this a fulltime business. Hopefully once the business grows i will add another developer or two.

 

how many of you perform unit testing? i have been looking into it but i can't say that i see the benefit of it given the amount of time it takes to write the tests. I consider just clicking around on my app and seeing what breaks and fixing that my testing... I also have no idea how to integrate unit testing into my project. All of the examples are really confusing to me. They all go basically like this.."so this is just a really simple test to see if a function returns TRUE, but you can see how you can do more involved testing" and in my head i'm repeatedly saying "nope, i really can't".

 

I've also been looking into version control. More specifically cornerstone2/subversion. I definitely see the benefit of having a repository and the ability for team members to work on the some files simultaneously as well as keeping different versions of the project as it progresses but right now i'm working on version 1. All that being said...it still is just me. Does it make more sense to put it under version control when its more than me developing on the project? It seems like a bit of overkill for it just being me.

 

Anybody give me some advice/suggestions?

 

Link to comment
Share on other sites

I can hopefully answer some of your questions. I personally need to get in the habit of writing unit tests - but I can tell you it does make a difference. I've been able to track down bugs quicker because I know what tests failed and with what sort of values it failed on. Also, with unit testing (as with any testing) it's another layer of QA to be sure what you are releasing is as bug-free as possible.

 

As far as a VC - it's definitely a good idea even if you are working alone now. Take a look into things like continuous integration (CI) to help out. You can automate many tasks (testing, doc writing, rebuild caches/minifiyng files, etc) via CI.

Link to comment
Share on other sites

thanks for the reply. Do you know of ANY tutorials that how to set up everything at once and go through developing a simple app to explain it all? version control/unit testing/continuos integration? Every example i've looked at of implementing any of these invoke more questions than answers for me.

 

I can't wrap my head around how to implement unit testing in the code i've already written?

 

Do i unit test the models, the controllers, or specific functions in each? 

 

How does continuous integration work on my web app? do i write tests and those are continuously running over my files?

 

Does CI work in conjunction with a version controller?

 

What exactly is a "build" and "compile" mean?

 

 

Link to comment
Share on other sites

Testing is probably best done before you write code, it makes you think through the functioning of code.  But its just as viable afterwards, though it will seem as extra work at that point.

 

Test Models, Test Forms, Test Classes, Test the UI, Test Controllers

 

Testing models and classes are the easiest, forms and controller testing require a bit more work and UI testing (which I haven't seen done much with webapps) can be the most difficult.  But with all things practice will make easier.

 

PHPUnit, Phing, Jenkins, PHP_CodeSniffer (phpcs), phpmd (php mess detector) are all tools I use while testing.  Selenium is pretty standard for testing the UI I think.

 

Jenkins is a continuous integration server, which I have configured to pull from my subversion repository and run several tasks against the codebase.  Currently it runs my tests, checks the code coverage of my tests, tells me all kinds of good stats, gives me pretty graphs, runs phpcs, phpmd, phplint.  Its really a nice reporting feature to automatically do the things I should be doing while I code.

 

While I code I'm always coding tests then writing code to pass tests, committing to subversion after pass and doing that over and over, so sometimes I forget about phpcs or another tool having the CI server catches my ass in all the things I should be doing.  I used to have phpcs and phplint checks on my pre-commit hook in subversion, but it was a pain to get working environment to environment.  A CI server can automate a great many things and make life simpler, though the setup takes a bit of time.

 

ZendCasts had a few Unit Testing vids, and while he makes use of the Zend Framework, its good introductory testing info.

 

Setting up Jenkins for PHP Prjects

Template for Jenkins Jobs for PHP Projects

 

Another useful source of information are the IRC channels on Freenode.net.  Nearly all of the bigger PHP projects have a channel there, where they talk about the project and offer help.

Link to comment
Share on other sites

I agree with the prior advice, but I have my own spin.

 

Read a test driven development book and if you buy into that, pick a clearly defined module to try that out and see if it works for you.

 

It's worth pointing out that there is a category of automated testing that is different from unit tests.  As mentioned, Selenium and Watir are two open source tools that allow you to automate tests for a web application.  You might find that these are of greater benefit to you in the near term in your goals of having tests for your application that you can run against a working system.

 

Having a source code mgmt system is huge, and as a long time user of vc, and having done a lot of work with subversion,  I'd recommend going directly to git.  There are numerous tutorials you can find.  You'll get value out of it, purely in having a way to track versions of your own code, and the day you screw up a source code file accidently, you'll be overjoyed that you took the time to set up something that lets you go check out a previous version, or compare the changes that you made, when a bug suddenly pops up in your latest release.

 

Link to comment
Share on other sites

thanks for the responses. Yeah i'm definitely going to attempt to get git working for me. It's extremely daunting as there are a bunch of new concepts that i don't quite understand yet. I think i'll get the hang of that before the fog starts to clear on unit testing. Unit testing is baffling me.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.