Browse DevX
Sign up for e-mail newsletters from DevX


jDefend: One Configuration File for All Your Test Scenarios  : Page 5

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




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Security Software with Simple Settings
jDefend enables you to test your software for any access violations by using simple configuration settings. Its security component allows you to enforce permissions at the test-driver and method levels. Each test driver and method (configured using the TestDriver and Method tags, respectively) can be configured to validate for a number of permissions or no permissions at all. These permission classes can be user-defined. You can configure each permission to be validated by a different SecurityManager, and you can set up your own SecurityManager.

Before running any test driver, jDefend checks for access violations by performing a permission validation on each of the permissions that were configured for that particular test driver. If jDefend finds any access violations, it won't execute the test driver. Only when the test driver is free of access violations will jDefend validate each method for access violations and then execute it.

If you want your test driver or method to run even if an access violation exists, set the abort flag to NO. On this setting, jDefend reports the access violation and continues the test run. For an explanation of security attributes, see the Security Attribute Descriptions table.

Security Attribute Descriptions

Security_Manager Fully qualified name of the Security_Manager class.
Ignore If you do not want jDefend to check for this Permission, set this value to YES.
E.g., YES/NO
Abort If you set this value to NO, jDefend will report the access violations it finds but continue the test run.
Method_Id Unique identifier within the scope of <Methods> tag.
This id tells jDefend to check this Permission before executing the method with this method id.
Class_Id Unique identifier within the scope of <TestDriver> tag.
This id tells jDefend to check this Permission before executing the TestDriver with this method id.

After implementing the test driver class and configuring the testDriver.xml file, type the following command to start the test run:

	java jDefend.DefendCode

Methods on Different Threads
Another neat feature that jDefend offers is it enables you to execute each method of the test driver on a different thread. You can establish method groups when methods have dependencies between them. For example, let's say Method Y has to be executed after Method X is, and both methods belong to one method group. This method group can be run on an independent thread from another method group, and from each thread, jDefend can simultaneously gather statistics such as time taken for executing each method/test driver, total number of test scenarios, number of failed scenarios, and number of successful scenarios. You can turn the logging and tracing on or off from the configuration file.

jDefend also can be used for purposes beyond unit testing—too many to discuss in just one article, but here's a summary of some of jDefend's other features:

  • You can selectively turn off the participation of your test drivers.
  • You can selectively turn off the participation of your test methods in a test driver.
  • You can setup method dependencies within a test driver, so that methods can be executed in a particular order.
  • The same method can be run in parallel on several threads.
  • jDefend automatically records the time taken and the success/failure status for each method.
  • Existing test drivers can easily be migrated to use the jDefend test harness.

    Author Note: jDefend is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
    Copyright (C) 2001 Subbu Vedula

  • Subbu Vedula is an independent contractor with extensive experience in client/server, Internet, and distributed application development. He also trains people in J2EE technologies. He has a master's degree in computer science.
    Comment and Contribute






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



    Thanks for your registration, follow us on our social networks to keep up-to-date