?
Solved

How to build a reusable testcase libray?

Posted on 2013-07-01
2
Medium Priority
?
392 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 35

Accepted Solution

by:
girionis earned 1000 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 29

Assisted Solution

by:pepr
pepr earned 1000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In this article I discuss my selections of the Top Four free Outlook OST File Viewers available. Open, view and read even damaged OST files by using these tools. They all provide a clear preview of all data such as emails, notes, tasks, calendars, e…
This month, Experts Exchange’s free Course of the Month is focused on CompTIA IT Fundamentals.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

770 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