Howto Setup IntelliJ as an IDE for ZebraTester Java Plugin Development
ZebraTester is built using Java and can be extended with plugins also written in Java, as well as using inline scripting for simple extension tasks. If a Java plugin is needed we will show how it can be developed in Java using a free IDE such as IntelliJ.
In general, use inline scripts for simple tasks, typically those that can be done using 3-5 lines of code. If something more involved is needed it’s usually time to roll up your sleeves and start coding in Java.
Java plugins are usually faster than Inline scripts. However, use of a 3rd party IDE is recommended for big projects. Also, Inline scripts can be developed and debugged inside ZebraTester.
By using IntelliJ, or some other IDE such as Eclipse, we get a nice code editor with code completion, syntax highlighting and all manner of project handling that lets us develop good code faster. Here’s how to set this up.
Setup a New Plug-in Skeleton In ZebraTester
Open Project Navigator in ZebraTester
Goto the Plugins folder. This is typically found in MyTests.
Press Create a new Load Test Plug-in
Define the Plugin Template and save
Generate Plug-In Code and Save
Using Multiple Classes and External Class Libraries
If a plugin consists of a single class and itself uses no external libraries, there is nothing further to be done, and this section can be skipped.
If a plugin requires the use of additional class libraries - in addition to those available in Java JDK 6.0 and package dfischer.utils (such as a database driver) - or if a plugin consists of more than one class, these must be available as “.jar" files before beginning the development of the plugin Main class. Note that the plugin Main class can never be part of the Java package, and must not itself be contained in a JAR Archive.
If additional ".jar” files are required, proceed as follows:
First load any recorded session.
Call the “Declare External Resources” Menu from the “Var Handler” menu:
Declare (add) all required jar files as External Resources:
Export the Declarations (they can later be imported in other recorded sessions):
You can now start developing your plug-in (see the previous chapter). Then move on to the next chapter when done.
Note: Starting from ZebraTester version 5.0 it’s no longer required to make any additions to the CLASSPATH of the Web Admin GUI. The revised Java “class loader” of ZebraTester will load all declared jar files instantly (on the fly).
All declarations for external local resources are always stored together with a recorded session (*.prxdat file) - and also only visible for this recorded session. There is no system-wide or product-wide declaration available. Therefore, if another recorded session uses the same plugin, you have to add the declarations for the external resources again to this other session.
Alternatively, you can also export the declarations and import them later by using the import and export icons which are located at the top of the window.
Once a load test program is generated, all external resources are automatically zipped together with the load test program, and the whole ZIP-archive is automatically transferred to the load generators (Exec Agents). There is no need to pre-install the external resources on the load generators.
Setup IntelliJ IDEA
Now that we have a code skeleton we develop the rest of the plugin using IntelliJ. We use IntelliJ as a Java IDE in this example. You can setup any IDE you might prefer, such as Eclipse or others as well.
Setup a New Project In IntelliJ
Goto File/New Project in the application menu
Choose Java SDK (Java 6 for version ProxySniffer 5.1C and below, Java 7 for ZebraTester 5.4I and above)
Click Next, then Next and name the project (Suggested name: Plugins).
Make sure to change the project path to point to the ZebraTester/ProxySniffer plugins folder and click Finish. This installation folder location differs, depending on your OS.
Your view should now look something like this:
Setup Project As Sources Root
Right-click the project Plugins. Look for the option “Mark Directory as” near the bottom of the list and choose the option Sources Root
Add ZebraTester As Library
Open File/Project Structure in the application menu. Choose Libraries and add a new Java library pointing to prxsniff.jar.
The file is located in the ZebraTester installation directory. Press OK to add the library to the project.
Develop The Plug-In
Now we can develop the plugin by double-clicking the plugin file whose skeleton we made in ZebraTester. Once you have developed your plugin you return to the ZebraTester GUI in order to compile and test it.
The actual code you add is usually located under the
public void execute(Object context) method:
Plugin Development Documentation
Further instructions on plugin development is available in the LoadtestPluginDeveloperHandbook.pdf located on https://www.zebratester.com/resources/manuals/ or found locally in your ZebraTester folder under Documentation. A guide to the actual plugin API is found in the Javadoc folder inside the Documentation folder in the installation directory.