aspose file tools*
The moose likes Testing and the fly likes creating a testing framework using JUnit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "creating a testing framework using JUnit" Watch "creating a testing framework using JUnit" New topic
Author

creating a testing framework using JUnit

Jean Miles
Ranch Hand

Joined: Aug 20, 2003
Posts: 53
Any pros or cons in the book on creating a testing framework using JUnit? Also, in estimating a project what additional percentage of time would you say writing test first approach would be vs not using this approach?
Vincent Massol
Author
Ranch Hand

Joined: Aug 09, 2003
Posts: 70
Originally posted by Jean Miles:
Any pros or cons in the book on creating a testing framework using JUnit? Also, in estimating a project what additional percentage of time would you say writing test first approach would be vs not using this approach?

WRT framework, no there is nothing related to this in the book. However, I would highly recommend you verify that such a framework does not already exist!
WRT TDD, I don't have any idea. Some hints. First, if you're not doing TDD, it's unlikely you'll get close to 100% test coverage. If you're not doing TDD you'll also spend a considerable amount of time refactoring your code when the code's first users try to use it. You can try asking the question on the TDD mailing list (on yahoogroups).
Thanks
-Vincent


-Vincent<br /><a href="http://www.manning.com/massol" target="_blank" rel="nofollow">JUnit in Action</a> author
Jean Miles
Ranch Hand

Joined: Aug 20, 2003
Posts: 53
Do you have any suggestion on creating test cases in packages that are similar package the test cases are written for. Example.
package: ebusiness.servlet
test cases package: ebusiness.servlet.test
I am not sure if test cases in frameworks test cases should be written for application across the enterprise? How do you handle project specific testing needs?
Tina Coleman
Ranch Hand

Joined: Dec 12, 2001
Posts: 150
What I've most often seen recommended is to put the test cases/classes in the same packages as the classes that they're testing. To keep test code segemented from "real" code, put them in a different source directory. So, you'd have a src/ebusiness/servlet directory structure and a test/ebusiness/servlet directory structure. Then you can easily package up the test classes separately, but the test classes still have package-layer access to the classes they're testing.
Vincent Massol
Author
Ranch Hand

Joined: Aug 09, 2003
Posts: 70
Originally posted by Jean Miles:
Do you have any suggestion on creating test cases in packages that are similar package the test cases are written for. Example.
package: ebusiness.servlet
test cases package: ebusiness.servlet.test
I am not sure if test cases in frameworks test cases should be written for application across the enterprise? How do you handle project specific testing needs?

I strongly recommend:

Where myproject/src/test contains your test classes.
Jean Miles
Ranch Hand

Joined: Aug 20, 2003
Posts: 53
What are reasons I would use a testing framework like cactus vs not use a testing framework.
Vincent Massol
Author
Ranch Hand

Joined: Aug 09, 2003
Posts: 70
Originally posted by Jean Miles:
What are reasons I would use a testing framework like cactus vs not use a testing framework.

First, you need to find the answer to: "why would I use a testing framework like cactus vs not use a testing framework.". Look at http://junit.org for answers (you can also search on the junit yahoogroups archives). Once you get that answer, you can solve the "why do I need cactus instead of using pure JUnit". Then you can check http://jakarta.apache.org/cactus!
Thanks.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Jean Miles:
Any pros or cons in the book on creating a testing framework using JUnit?

What exactly do you mean by "creating a testing framework"? JUnit *is* a testing framework, isn't it?
Also, in estimating a project what additional percentage of time would you say writing test first approach would be vs not using this approach?

Well, there is an initial learning curve, of course. But after that I would say that using TDD will actually *save* time. The time spent writing the tests will be paid back manyfold by reduced debugging time and a better decoupled (easier to maintain/extend) design.


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
Jean Miles
Ranch Hand

Joined: Aug 20, 2003
Posts: 53
My question wasn't specific on what I wanted to ask. I wanted to know how to organize the test classes. Do I create a framework of test classes to mirror my existing classes or put the test classes in same package as the existing class or put test classes in one large package?
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Take a look at this thread.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: creating a testing framework using JUnit