Solved

How to build a reusable testcase libray?

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

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

In this article, you will read about the trends across the human resources departments for the upcoming year. Some of them include improving employee experience, adopting new technologies, using HR software to its full extent, and integrating artifi…
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
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…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

860 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