Zephyr ZBots & ZIPs

The next level of automation integration

Use any automation tool. Kick off automation execution and bring back the results into Zephyr.
This guide is intended for developers

ZBot Overview

Zephyr Bots or ZBots are software agents that reside on target automation systems and form the link between the Zephyr Server and the automation tool being used on the target automation system. Based on user action in Test Case Execution (where the "E" button is clicked and an automation script(s) is kicked off), the Zephyr Server connects with the target ZBot and sends over execution information to execute an individual test script or multiple test scripts.

If you are using Selenium, the following documentation will help you get going quickly:

  • Getting Started when using Selenium (JAVA) with ZBot [HTML] [PDF]

ZIP Overview & Lifecycle

A ZIP or a Zephyr Interceptor Program is an extension to the execution utility of a ZBot. It is used to intercept the default execution flow of automation scripts in order to perform customized actions. While ZBots comes pre-packaged with a default ZIP, you can also write a custom ZIP. Currently, ZIPs written in JAVA are supported.


The Lifecycle of a ZIP is very closely tied to that of a ZBot. The following flow shows what the ZBot (bolded) actions are and {zip} shows where ZIP actions can interface with that flow:

Batch Started: Update Batch Status {zip}

	Before Test script execution starts: Update Batch Status {zip}

	Run Test script: {zip}

		In sequential mode, ZBot will wait for each script to finish,
       		gather the process status and update test status in Zephyr Server via a webservice.

		Exit Status 0 is translated as Pass.

		Any non-zero values is treated as Fail.

		In parallel mode, it will launch them all without waiting for it to finish. It also, doesnt update the test execution status.

	Update Test script Execution Result {zip} 

	After testcase Executed {zip} 

Batch Finished {zip}

The Zephyr server hands off the entire batch of testcases (kicked off from within the UI) to the appropriate ZBot. ZBot calls following routines (methods) on ZIP, each of which can be intercepted and re-written in a custom ZIP.
Method Description
public void batchStart() Gets called once per execution batch
public void testcaseExecutionStart() Gets called once for every testcase
public void testcaseExecutionRun() It spawns a dedicated native process for each testcase. Serial mode waits for the process to finish. Parallel mode doesn't. In custom ZIP this could be done in a separate Thread and that dedicated thread can wait for the process to finish. Alternatively, custom ZIP can store all processIDs in a hash and wait for them to finish in batchEnd()
public void testcaseExecutionResult() Gets called once for each testcase. In parallel mode, it wont be very useful as it wouldn't know about the status of execution
public void testcaseExecutionEnd() Gets called once for each testcase. In parallel mode, it will get called immediately after testcase kickoff
public void testcaseExecutionEnd() Gets called once for each testcase. In parallel mode, it will get called immediately after testcase kickoff
public void batchEnd() Gets called once per execution batch. In parallel mode, this method can be used to wait for all testcases to finish and send the results

How to write a ZIP

You can write a customized ZIP and deploy it with your ZBot to perform specialized tasks. For example, your ZIP could intercept the ZBot's action of kicking off the automation tool by first fetching the automation script from a source control system or by setting up the right test environment. At the end of the execution, your ZIP could intercept the ZBot and do other interesting things like analyze the automation results, reset the test environment, update the Zephyr server with results etc. A ZIP can be as flexible as you want it to be.



The prerequisite for writing a ZIP is knowledge of JAVA and a JAVA IDE (e.g. Eclipse). There are 3 major tasks associated with it:
  1. Create a JAVA project with dependency on zephyr-socket-server-2.6.jar and other libraries that your code might need.
  2. Create JAVA classes (say com.testzip.zip.TestCompleteLauncher.java and extend com.thed.launcher.DefaultZBotScriptLaunch)
  3. Provide implementation, compile the project and create a jar file (say testzip-ZIP-1.0.jar)
An Example
(NOTE: This is not the only way of implementation and that this could be implemented in many different ways.)
  1. public void batchStart()
  2. Get the list of testcases for execution and start your suite.
  3. testcaseBatchExecution.getTestcaseExecutionList() 
  4. Make your testscripts to write their status to a flat file or DB Wait for the suite to finish.
  5. public void testcaseExecutionStart()
  6. Skip, dont do anything
  7. public void testcaseExecutionRun()
  8. Skip, dont do anything
  9. public void testcaseExecutionResult()
  10. Read the results from file/DB (created in step 1), get the results for currentTestcaseExecution and call scriptUtil.updateTestcaseExecutionResult()
  11. public void testcaseExecutionEnd()
  12. Perform any cleanup you need to
  13. public void batchEnd()
  14. Perform any cleanup for the batch (e.g. results file, db etc)

Deploying a ZIP

Follow these directions to deploy your ZIP on the machine where your ZBot is installed. You can have only one ZIP associated with a ZBot. You can however have a different ZIP for each of your ZBot installations.
  1. In $ZBOT_HOME\conf\wrapper.conf, add following entries below
  2.           wrapper.java.classpath.5=../plugin/ com.thed.launcher.DefaultZBotScriptLaunch (line 17)
              wrapper.java.classpath.6=../plugin/testzip-ZIP-1.0.jar
              wrapper.java.classpath.7=../plugin/commons-lang-2.4.jar
              wrapper.java.classpath.8=../plugin/others.jar
    
  3. Copy attached jar file to $ZBOT_HOME\lib
  4. Make sure scriptLauncher property is set in zbot.properties
  5. scriptLauncher=com.testzip.zip.TestCompleteLauncher.java
    
  6. Restart ZBot
  7. Test your implementation by kicking off an execution from with the Test Case Execution application in Zephyr.

Samples

Check out this sample (binary and source, called qtpSelenium.jar and src.zip) written to execute Selenium testcases and read the results flat file. Please use this only as a reference as the code makes assumptions about files and paths to be available on the automation box.
Keep checking back here for more sample scripts.
Check out the FAQ section on the community site to get your questions answered.

Community

Check out the Zephyr Developer Community for the latest news, FAQs, samples and discussions.