How do we document unittest cases? Do we identify the class/method name while documenting unit test cases. Thanks
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
posted
0
I am not sure I understand your question. I typically name a test method so that it becomes obvious which scenario I am testing, such as testSquareOfTwo or testThrowsExceptionForNegativeValue. Besides that, the tests are typically so easy to read, that they don't need more documentation. Can you give us an example of a test you want to document further?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Pradeep, There are some common conventions that help with this. Unit test classes are named with the name of the class + the word test. So HelloTest.java would be tests for the Hello class. This documents which class the tests pertain to. Unit test methods are usually named with test + the name of the method + any extra information. Some people append underscores between the parts. So testMethodForNull would test the method "Method" for the condition where null is passed in.
This may be way off-topic for you. But, you could also manage traceability relationships in some requirements management tool like RequisitePro. That way, you could tell exactly what unit tests are associated with the methods in your components, etc. It sounds like you are looking for something that is more coupled to your source code though.
Thanks for your replies. My manager want to me to list the unit test cases in a document with a brief description. Is this the process normally followed? :roll: I thought we just code the unit test case in the class. Simply, I want to know if documentaion is required, can't I directly code the test case.
Warren Dew
blacksmith
Ranch Hand
Joined: Mar 04, 2004
Posts: 1328
posted
0
Originally posted by Pradeep Bhat: My manager want to me to list the unit test cases in a document with a brief description. Is this the process normally followed? :roll:
Yes - where the document is the source file for the test class and the brief description is the name of the test case. But somehow, I don't think that's what your manager has in mind....
Lasse Koskela
author
Sheriff
Joined: Jan 23, 2002
Posts: 11962
5
posted
0
Originally posted by Pradeep Bhat: My manager want to me to list the unit test cases in a document with a brief description. Is this the process normally followed? :roll:
It sounds like your boss wants to check a checkbox in his deliverable list... Just try to be as brief as you can -- it's probably of no use to try getting him to forget the document completely (assuming that your process requires such a document among the deliverables).
If, like Ilja, you've been using meaningful names for your unit tests, take a look at TestDox which will create a "formatted" version of your test classes and methods.
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
posted
0
Originally posted by Pradeep Bhat: Thanks for your replies. My manager want to me to list the unit test cases in a document with a brief description. Is this the process normally followed? :roll:
Write a small perl script which traverses your test classes and generates
testMethodFooThrowsExceptionWhenNullParameterPassed() Test that method foo throws exception when null parameter passed.
from them.
Tina Coleman
Ranch Hand
Joined: Dec 12, 2001
Posts: 150
posted
0
Run JavaDoc on your test classes, if you have any sort of method description there. If you're slick, then you can apply a transform on the documentation to get a document in exactly the format your boss wants. If you're like me, and not slick, at least you've got an easy set to copy/paste from.
Wrote the test code and then copied the method description into a document. Sorry, I do not know PERL.
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
posted
0
Originally posted by Pradeep Bhat: Wrote the test code and then copied the method description into a document. Sorry, I do not know PERL.
Well, with Java regular expressions, it wouldn't be hard to automate, either. It's just even simpler using Perl...
lakshmi bvr
Greenhorn
Joined: Jun 01, 2004
Posts: 6
posted
0
Hi,
can u follow like this, just write test case id, test case name with the descripttion, actual result of each and every function in the excel sheet or word document. i hope u can follow like this.