Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Documenting unit test cases

 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do we document unit test cases? Do we identify the class/method name while documenting unit test cases.
Thanks
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
author & internet detective
Posts: 41944
911
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Pradeep bhatt
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
blacksmith
Posts: 1332
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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....
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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).
 
sharp shooter, and author
Posts: 1913
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Pradeep bhatt
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your replies.
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome!
So tell us - what will you do?
 
Pradeep bhatt
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wrote the test code and then copied the method description into a document. Sorry, I do not know PERL.
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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...
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Yes, my master! Here is the tiny ad you asked for:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic