Despite learning the importance of
testing software during the computer science course, I entered the field of IT from web sites > web applications (initially in CF and then PHP) > finally moving onto
Java - thus never really got heavlity into testing.
Though I do tend to test my code but its never definitive testing and its certainly never been test driven development. I am in the process of re-writing an application and would like some advice on testing.
I have started the development from backend, have just finished tidying up the database tables etc. I have now moved onto writing business model classes and wrote a couple of them. Beofre I proceed, I would like to unit test my code.
How strict is unit testing, for example, I have written a Database class, CarDAO which extends Database and a CarBean which extends CarDAO. Should I now test each of these "units" individually so write a DatabaseTest, a CarDAOTest, a CarBeanTest etc. The CarBean also required some information from the corporate so I had to also start writing the CorporateDAO and CorporateBean.
Can someone please advise on a good strategy to testing the abvoe using
JUnit (my Database class is using the
tomcat JNDI datasource settings to connect to the MySQL database - should I also write a stand alone connection to test outside tomcat environment).
Moving on from here should I write the test classes first based on the business requirements and then write the code, bearing in mind that the application is written already but very badly.
Apologies for going on but I am little bit confused abou some matters and wanted to seek clarification and guidance to emabrk upon a good testing strategy.
Any help will be most appreciated.