dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


advertisement
 

jDefend: One Configuration File for All Your Test Scenarios

How would you like to have a test driver that you don't need to recompile every time input parameters change?


advertisement

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps




very developer, at some point, has implemented a test driver to test his or her code. The alternative is writing a custom test driver for each test scenario. The custom driver would have to read the input data, parse it, turn it into objects, and then use those objects for each test scenario. How would you like to have a test driver that you don't need to recompile every time input parameters change?

With the open source jDefend test driver suite, you can configure all the input parameters and pass them to your test driver using a single XML-based configuration file. jDefend's parser class parses the configuration file and prepares all the test drivers listed for execution. It then executes each test driver—even on a different thread—for faster execution of the test scenarios. (Figure 1 shows the various components of the jDefend suite.)



Figure 1. jDefend Components: The jDefend suite is made up of various components.
In this article, I'll demonstrate how the jDefend test suite can make your Java code testing quicker and simpler, and I'll discuss how it also can simplify security testing.

jDefend in Action
To better understand jDefend's functionality, follow the test procedure for a simple class. Begin with a Java object called Student.

Listing 1: Student.java
package example; public class Student { private String name; private Address addr; public void setName(String n) { System.out.println("setName called"); name = n; } public String getName() { return name; } public void addressIs(Address a) { addr = a; } }

Next, load a class called StudentManager, which has three operations: add, remove, and find Student.

Listing 2: StudentManager.java
package example; import java.util.Vector; public class StudentManager { Vector students = new Vector(); public void add(Student s) { System.out.println("Entering StudentManager::add(Student s) "); students.add(s); } public void remove(Student s) { System.out.println("Entering StudentManager::remove(Student s) "); students.remove(s); } public Student findStudent(String name) { System.out.println("Entering StudentManager::findStudent(String name) "); Student stud = null; for(int i=0; i<students.size(); i++) { stud = (Student)students.get(i); String sname = stud.getName(); if (sname != null) { if (sname.equals(name)) { break; } } } return stud; } }



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date