Create JBehave.for Java Agent from Automation Host v 1.3.8 or Later

In this article, we will walk you thru how to create and configure a JBehave.for Java agent to a specific Automation Host machine.

PREREQUISITES:

  1. Activate Automation Integration

  2. Install and Register the Automation Host

Step 1

Download the sample JBehave.automation project at https://github.com/QASymphony/jbehave-agent-sample and save it to your local machine.

  • On Windows. D:\jbehave-agent-sample

  • On Linux or Mac. /usr/local/jbehave-agent-sample

Note:

  • In this sample, we use maven 3.3.9 and Ant 1.10.1 to Build the project (you can use another version, which you are familiar with)

  • The sample project uses qTest Log Collector, which is a Story Reporter. You can find it being listed in the screenshot of pom.xml file below (for maven build).

Step 2

Execute the command below in your JBehave.automation project folder to compile automation project and package it:

On Windows

D:\jbehave-agent-sample> mvn clean compile package integration-test

On Linux or Mac

/usr/local/jbehave-agent-sample$ mvn clean compile package integration-test

Step 3

Access to Automation Host UI then Click on + Add button in the right corner of Agents list.

You will be presented with New Agent dialog, as shown below.

Input General Information

  • Agent Name: name of the new agent, e.g. New Agent

  • qTest Manager Project: select a project that the new agent will be associated with, e.g. qConnect - Sample Project

  • Agent Type: JBehave.for Java

Test Scripts

  • Directory (required): specify the path to your JBehave.source code that you have downloaded in step 1

  • Story Root Directory (required): provide a path to all JBehave.stories

  • Scripting libs (optional): provide paths to the dependency libraries (files or folders) in your JBehave.source code that you have downloaded in step 1. You can input one or multiple paths, separated by a comma. If all of your libraries are in a folder, simply put its path here

  • Include (required): define patterns to scan for tests in the automation project (methods/classes) using ANT Style Pattern Matcher. Use a comma as a separator between patterns.

  • Exclude: define patterns to ignore tests (method/classes) when scanning using ANT Style Pattern Matcher

HINT: ANT Style Pattern Matcher uses the following rules:

  • ? matches one character.

  • * matches zero or more characters.

  • ** matches zero or more 'directories' in a path.

Test Scripts example on Windows

  • Directory: D:\jbehave-agent-sample\org.qas.jbehave.example

  • Story Root Directory: D:\jbehave-agent-sample\org.qas.jbehave.example\src\test\resources\org\qas\jbehave\example\stories

  • Scripting libs: D:\jbehave-agent-sample\run

  • Include: **/*.story 

  • Exclude: leave it blank

Test Scripts example on Linux or Mac

  • Directory: /usr/local/jbehave-agent-sample/org.qas.jbehave.example

  • Story Root Directory: /usr/local/jbehave-agent-sample/org.qas.jbehave.example/src/test/resources/org/qas/jbehave/example/stories

  • Scripting libs: /usr/local/jbehave-agent-sample/run

  • Include: **/*.story 

  • Exclude: leave it blank

Execution

JBehave.Agent supports 3 execution modes to Build and run your test project: Command, Ant, Maven. You need to provide different information depending on the execution mode you choose.

Execution mode: Maven

  • Executable home: input the path to the directory where Maven is installed

  • Goal: input the goal defined in your POM file to deploy your project

  • POM file: provide the path to your POM file, which is located under the home directory of your test source code. Please note that this is the relative path under your scripting directory.

  • Command arguments: provide any additional arguments to execute the target

Screenshots below shows an example of Maven execution mode information.

Windows:

  • Executable mode: Maven

  • Executable home: D:\apache-maven-3.3.9

  • Goal: integration-test

  • POM file: pom.xml

  • Command arguments: leave it blank

Linux or Mac

  • Executable mode: Maven

  • Executable home: /usr/local/Cellar/maven/3.3.9/libexec

  • Goal: integration-test

  • POM file: pom.xml

  • Command arguments: leave it blank

Execution mode: Ant

  • Executable home: path to the directory where Ant is installed

  • Target: specify which target to be executed. This is the name of the target which has been defined in your Build file.

  • Build file: the path to your Build file in which the above target is defined. This file is located under the home directory defined in Test Scripts section of your test source code

  • Command arguments: provide additional arguments to execute the target

Screenshots below shows an example of Ant execution mode configuration

Windows:

  • Executable home: D:\apache-ant-1.10.1

  • Target: test

  • Build file: build.xml

  • Command arguments: leave it blank

Linux or Mac

  • Executable home: /usr/share/apache-ant-1.10.1

  • Target: test

  • Build file: build.xml

  • Command arguments: leave it blank

Execution mode: Command

  • Executable home: input the path where JAVA/JDK is installed

  • Command: the command to execute your scripts

  • Command arguments: target directory where all built outputs are located plus any needed arguments

Below are examples of Command execution mode configuration.

Windows:

  • Executable mode: Command

  • Executable home: C:\Program Files\Java\jdk1.8.0_144

  • Command: java

  • Command arguments: -cp D:\jbehave-agent-sample\org.qas.jbehave.example\target\* org.junit.runner.JUnitCore org.qas.jbehave.example.junit.JUnitRunner

Linux or Mac

  • Executable mode: Command

  • Executable home: /usr/local/jdk1.8.0_144

  • Command: java

  • Command arguments: -cp /usr/local/jbehave-agent-sample/org.qas.jbehave.example/target/* org.junit.runner.JUnitCore org.qas.jbehave.example.junit.JUnitRunner

 Click Save to finish creating JBehave.for Java agent.

If a failure occurs during test submission, the Failure Log will be included as a text file attachment in the Test Log details.