The Right Unit Testing

Recently, one task for me was to test a software that is not very complicated. When I got the release of this software, I sit with the programmer and asked him a couple of questions about how much testing was done especially unit testing. All the answers that came from the developer were very positive and confirming that the software does the required functions well. At that point, I was telling my self that I am not going to find any issues with that software especially functionality issues.

Test results of this software showed around 18 issues that need to be discussed and fixed. Those issues varied between performance issues, usability issues in addition to functionality issues that could be found if unit testing was done in the right way.

Again and again, this raises the need to train programmers on testing in order for them to do well in it especially unit testing and integration testing. This will relief them from fixing those issues reported by testing team since those issue will no longer exist.

All the best…

8 Comments

Jan Matilainen

about 11 years ago

Agreed! The unit test needs to contain a bit more than just a check if the function exists :D

Reply

Kapil Saxena

about 11 years ago

Agreed! But will unit testing cover all possible scenarios? I don't think so.. So, even after training programmers how to increase unit test coverage doesn't really mean to expect less number of bugs.

Reply

Jerry Levesque

about 11 years ago

Unit testing is rather vague terminology. That could cover a broad range of possibilities. Sometimes, the "unit" is a pre-existing product and the developer is simply adding some new software functionality to the product. Other times, the "unit" and the software are being developed simultaneously and in conjunction with one another. The hardware unit and the software both need to be tested as parts of a complete system. When testing a complete system, there may not be any standard method or model that one can go by, and one may not be given very specific requirements or criteria. That's when testers have to use their own initiative and creativity and think up their own "what if" scenarios. Think of the Global Positioning System. It's comprised of a satellite network and it's software system, plus the ground receiving units and their software system all working in conjunction with one another. On top of that there is a satellite launching system that must put the satellites in very precise geosynchronous orbits. There is (was) no real model for testing such a system. People had to get creative. Obviously, one wants to make sure that the satellite network works in conjunction with the receiving units before spending tens of billions of dollars to put the satellites into orbit. So, maybe, the satellites are stationed on the ground and the receiving units are put up in planes. Only, one has to keep in mind that the satellites send out precise clock signals to the receivers, and the satellite clocks run slower on earth than they would in high orbit due to the effects of gravity. One would have to calculate the difference between the clock speed on earth and the clock speed in orbit and have the programmers modify either the satellite software or the receiver software to simulate satellites in space, when the satellites are actually earthbound. It turns out that coronal mass ejections from the sun can effect the cesium decay rates of the nuclear clocks used by the satellites. Should the system detect coronal mass ejections and correct for the change in clock speed? Has anyone even considered that? Sometimes there are things that one runs into in testing that the system designers have not anticipated. All one can do is inform them and let them decide what to do about it. When it comes to unit testing in conjunction with software applications, you pretty much have to take it on a case by case basis, and tailor your testing to fit the particular system under test.

Reply

Jerry Levesque

about 11 years ago

To the moderator: there is a typo in the comment I just submitted. The first word in the second to last paragraph should be "It", not "I". It should say, "It turns out that..."

Reply

Anwar Bosbool

about 11 years ago

Kepil: There are different level of coverage (statement coverage, branch coverage,... etc) and you may decide which level to go with. if the unit (class) is very complicated, then covering all possible scenarios might be impossible or infeasible. Jan: Functionality tests should prove if the function is correct or not. Jerry: In unit testing, a unit should not be more than one class. This class should be tested in isolation from other parts of the system (hardware/software).

Reply

Anwar Bosbool

about 11 years ago

Jerry: Your comment is corrected. Thanks a lot.

Reply

Gay Kenington

about 11 years ago

One question I have - how often do you have that problem in that organisation? Does the development team as a whole need a bit of guidance on what to test, or was it just that individual? There should be ways of you (or your manager) discussing the need for better unit testing and organising something - either a team training or a 1-2-1 coaching session. In my experience, people want to do do their job well, so the challenge is to help the developers improve... without you becoming the tester they all dread!

Reply

Anwar Bosbool

about 11 years ago

Thanks Gay for your comment and sharing your experience. The whole development team needs guidance and training about the importance of the right unit testing and how to perform it. Before that, management should get more aware about the importance of the right unit testing in order to support it and emphasize on it in addition to arranging for training or coaching sessions for the development team.

Reply

Leave a Comment

Leave a Reply to Anwar Bosbool or Cancel Reply

Please be polite. We appreciate that.
Your email address will not be published and required fields are marked