Solved

How to build a reusable testcase libray?

Posted on 2013-07-01
2
385 Views
Last Modified: 2013-12-13
Hi,

I hope I am asking this correctly.

I was wondering if I can get a guidance or example on how to go about building a JUnit reusable testcase library.

If I am testing a method that checks for a string, I would like to create one testcase and use that over and over again on my other project.

If I am comparing integers on a method, I wouldl ike to write up one testcase and use that in other projects.

I don't know if this is done regularly by other programmers.
Any advise will be greatly appreicated.
0
Comment
Question by:dkim18
2 Comments
 
LVL 35

Accepted Solution

by:
girionis earned 250 total points
ID: 39292379
You can write a superclass with all the necessary test methods you need, and then extend this class with every test case. By doing so you can reuse the commonly used test cases and you can define specific functionality in each subclass.
0
 
LVL 28

Assisted Solution

by:pepr
pepr earned 250 total points
ID: 39292384
Independently on a language and a unit test framework... When you want to reuse the method in other projects, how would you do that? If you find a bug in the method (in future), how would you fix the bug in all the projects?

The simple but labour-intensive way is to copy the code of the method to the other projects from one of the projects that you consider a referential one. It can be a project that is used just for the development and for testing of that method. When you find the bug in the methode elsewhere, you write the new test for the reference project and fix the code there. Then you copy the code of the method to the other projects.

The alternative way is to create the library/package for implementing the functionality. After fixing the bug you only rebuild the project that depend on the functionality. This is probably what should be prefered. However, it may be the case that the first approach is more economic at first. It depends on more things.

Definitely, you should start somehow (with unit testing...). Then you gradually gain the experience, and you will know what next.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Java DateChooser? 3 29
netstat -ano | find "8000" and taskkill /f /pid 2984 3 30
more than one jdk and one jre 1 30
xampp tool 12 24
Let’s list some of the technologies that enable smooth teleworking. 
Healthcare organizations in the United States must adhere to the guidance of both the HIPAA (Health Insurance Portability and Accountability Act) and HITECH (Health Information Technology for Economic and Clinical Health Act) for securing and protec…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
XMind Plus helps organize all details/aspects of any project from large to small in an orderly and concise manner. If you are working on a complex project, use this micro tutorial to show you how to make a basic flow chart. The software is free when…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now