Re: Re: Unit Testing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Philip Thompson wrote:
On Apr 27, 2009, at 11:38 AM, Simon wrote:

As a programmer, i always test what I'm coding as i code it (mostly to
make sure i dont include typos), but i feel it is best to make proper
testing once the component is ready and working fine.  If your project
is large, it might be a good idea to break it in several 'modules' or
section if possible and treat each of them as separate projects
(testing would be done on a module once this one is ready).

You may be interested in looking for information on the net on 'IT
project management' which usually describe when is the best time to
test according to a certain structure...

Simon

On Mon, Apr 27, 2009 at 12:16 PM, Nathan Rixham <nrixham@xxxxxxxxx> wrote:
Philip Thompson wrote:

Hi. I did some searching in the archives, but didn't quite find what I was
looking for. Maybe a few of you can assist me...

We have an application that's currently in production, but we're
constantly modifying/upgrading it. We did not do unit testing early on
because of the lack of time. Now that some time has opened up, we're
considering unit testing. My question is..... is it reasonable to start unit testing at this point in time with the application mostly built? Besides being really time-consuming, what are the pitfalls of starting unit testing
at this stage?

Thanks in advance,
~Philip

maybe a useless answer, but, no pitfalls - just do it - I'm always surprised by my unit test results, its invaluable and it's never too late to start.

just think about the next years worth of bugs found by the client not being
there!

A question I have about unit testing. The point is to test individual "units"... correct? So, let's say I have this core class which creates instances of other classes. Well, if I only want test the core class, I don't want to instantiate the other classes... correct? Example:

<?php
// Core.php
require ('Class1.php');
require ('Class2.php');

class Core {
    public function __construct () {
        $this->class1 = new Class1 ($this);
        $this->class2 = new Class2 ($this);
    }
}

// CoreTest.php
require ('../PHPUnit/Framework.php');
require ('../includes/Core.php');

class CoreTest extends PHPUnit_Framework_TestCase {
    protected function setUp () {
        $this->core = new Core();
    }
}
?>

So, here, Class1 and Class2 will be instantiated. However, I don't really care for them to be so that I can test all the methods in the core class. Is this a perfect example of how the original design of the core class is not conducive to implementing unit tests? Without rewriting the core class, is there a way to test this?

Thanks,
~Philip

well Class1 and Class2 should have there own unit tests, so by the time you get to Core you know the others are good so it doesn't matter if they are called or not.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux