Solved

How to build a reusable testcase libray?

Posted on 2013-07-01
2
387 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
A list of useful business intelligence software.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

776 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