Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the most convincing way to require formalized unit testing?

This certainly presupposes that unit testing is a good thing. Our projects have some level of unit testing, but it's inconsistent at best.

What are the most convincing ways that you have used or have had used with you to convince everyone that formalized unit testing is a good thing and that making it required is really in the best interest of the 'largeish' projects we work on. I am not a developer, but I am in Quality Assurance and would like to improve the quality of the work delivered to ensure it is ready to test.

By formalized unit tests, I'm simply talking about

  • Identifying the Unit Tests to be written
  • Identifying the test data (or describe it)
  • Writing these tests
  • Tracking these tests (and re-using as needed)
  • Making the results available
like image 391
not-bob Avatar asked Sep 23 '08 11:09

not-bob


People also ask

What is the testing strategy used for unit testing?

Unit Testing Techniques:Black Box Testing - Using which the user interface, input and output are tested. White Box Testing - used to test each one of those functions behaviour is tested. Gray Box Testing - Used to execute tests, risks and assessment methods.

When should the unit testing be performed?

Unit testing is the first testing phase and it is practiced before moving to the phase of integration testing. Hence, before moving for the next testing level, make sure to fix all the identified bugs in the unit testing phase.


2 Answers

A very convincing way is to do formalized unit test yourself, regardless of what your team/company does. This might take some extra effort on your side, especially if you're not experienced with this sort of practice.

When you can then show your code is better and you are being more productive than your fellow developers, they are going to want to know why. Then feed them your favorite unit testing methods.

Once you've convinced your fellow developers, convince management together.

like image 81
Rik Avatar answered Oct 19 '22 19:10

Rik


I use Maven with the Surefire and Cobertura plugins for all my builds. The actual test cases are created with JUnit, DbUnit and EasyMock.

Identifying Unit Tests I try to follow Test Driven Development but to be honest I usually just do that for the handful of the test cases and then come back and create tests for the edge and exception cases later.

Identifying Test Data DbUnit is great for loading test data for your unit tests.

Writing Test Cases I use JUnit to create the test cases. I try to write self documenting test cases but will use Javadocs to comment something that is not obvious.

Tracking & Making The Results Available I integrate the unit testing into my Maven build cycle using the Surefire plugin and I use the Corbertura plugin to measure the coverage achieved by those tests. I always generate and publish a web-site including the Surefire and Cobertura reports as part of my daily build so I can see what tests failed/passed.

like image 34
Brian Matthews Avatar answered Oct 19 '22 21:10

Brian Matthews