Configure BDD for ALM Octane

ALM Octane
6 min readMar 6, 2019

1 — Overview

Before your start check out also the following 2 articles:

In this article, we will describe how to configure your Behaviour Driven Devleopment (BDD) project with ALM Octane.

As an example we will you the following pieces of software:

  • ALM Octane 12.60 CP7
  • IntelliJ Community Edition 2018.2.2
  • Apache Maven 3.5.4
  • Cucumber (info.cukes) 1.2.5.
  • ALM Octane Cucumber JVM 12.55.7
  • UFTPro (LeanFT) 14.03.
  • JUnit 4.12

Topics we are going to cover within this article:

  • Pre-requisites
  • BDD Workflow in ALM Octane
  • Setting up Java Project
  • Create simple MAVEN project
  • Configure ALM Octane Connection
  • Manage References and Dependencies
  • Working with BDD
  • Create a gherkin test in ALM Octane
  • Download the gherkin test into your IDE (IntelliJ)
  • Create Step Definition Class
  • Define a Testrunner Class
  • Build your project locally
  • Setting up Jenkins
  • Create a new maven job for your pipeline
  • Add build step
  • Add post build step
  • Run pipeline from ALM Octane or Jenkins
  • View Gherkin Test Results in ALM Octane

2 — Pre-requisites

To get started with BDD in ALM Octane, make sure you have the following pieces of software & libraries installed:

3 — BDD Workflow in ALM Octane (simple version)

The workflow between the teams is defined within ALM Octane, also as ALM Octane will be the single source of truth, it is important to follow the workflow as defined below to gain the maximum of pace in the collaboration within your agile teams.

Workflow between the roles, their responsibilities and used software.

4 — Setting up Java Project (IntelliJ)

4.1. — Create a simple MAVEN project in IntelliJ

4.2. — Establish Connection with ALM Octane from your IDE (IntelliJ)

As a very first step, to go File>Setting…>ALM Octane and enter the URL of the ALM Octane workspace you want to connect with.

This dialog is only available, if you have installed the ALM Octane plugin.

4.2. Manage References and Dependencies

As this article was prepared with the test automation tool UFTPro (LeanFT), the references for LeanFT are added to the project. If you are working with Selenium, Appium, etc. manage the references accordingly.

Goto File>Project Structure…>Libraries and add the libraries of LeanFT. These are found under the %LeanFTInstallationDir%\SDK.

LeanFT references added to the Java project in IntelliJ project structure.

Now add the following dependencies to your pom.xml file:

<dependencies>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-java</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-junit</artifactId>
<version>1.2.5</version>
</dependency>
<dependency>
<groupId>com.hpe.alm.octane</groupId>
<artifactId>octane-cucumber-jvm</artifactId>
<version>12.55.7</version>
</dependency>
<dependency>
<groupId>com.hp.lft</groupId>
<artifactId>sdk</artifactId>
<version>14.3.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.hp.lft</groupId>
<artifactId>report</artifactId>
<version>14.3.0</version>
</dependency>
<dependency>
<groupId>com.hp.lft</groupId>
<artifactId>unittesting</artifactId>
<version>14.3.0</version>
</dependency>
<dependency>
<groupId>com.hp.lft</groupId>
<artifactId>verifications</artifactId>
<version>14.3.0</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
</dependencies>

Make sure that the LeanFT dependencies exists in your local Maven repository.

5 — Working in BDD culture through ALM Octane

5.1 — Create user story in your backlog

User stories can be created in the Backlog Module of ALM Octane

… and attach a gherkin test as acceptance criteria.

At this step the Phase of the Gherkin Test is not automated and the coverage is empty.

Gherkin tests can be created as acceptance criteria for the user story and / or feature.

5.2 — Download the gherkin test in to your IDE (IntelliJ) using ALM Octane plugin.

ALM Octane plugin shows only the information relevant for the working user.

The downloaded feature has a specific ALM Octane tag (i.e. @TID165001REV0.2.0) -do not remove it.It is important for the continuous integration pipeline by your CI server.

5.3 — Create Step Definition Class

After you have download the feature file from ALM Octane, just let it run with cucumber. It will generate a sample skeleton script, which you can use as a base for your step definition class. Here is a sample script for the step definition class.

package bdd.octane;

import com.hp.lft.report.ReportException;
import com.hp.lft.report.Status;
import cucumber.api.PendingException;
import cucumber.api.java.en.Given;
import cucumber.api.java.en.Then;
import cucumber.api.java.en.When;
import java.net.URI;
import java.net.URISyntaxException;

import com.hp.lft.report.Reporter;
import com.hp.lft.sdk.*;
import com.hp.lft.sdk.web.*;
import com.hp.lft.unittesting.*;
import unittesting.UnitTestClassBase;


public class step_definition extends UnitTestClassBase {


@Given("user and password are provided")
public void user_and_password_are_provided() throws Exception {
ModifiableSDKConfiguration config = new ModifiableSDKConfiguration();
// Write code here that turns the phrase above into concrete actions
config.setServerAddress(new URI("ws://localhost:5095"));
SDK.init(config);
Reporter.init();
Reporter.reportEvent("step user and pw", "Execution", Status.Passed);
//throw new PendingException();
}

@When("user clicks on login")
public void user_clicks_on_login() throws ReportException {
// Write code here that turns the phrase above into concrete actions
Reporter.reportEvent("step user and pw", "Execution", Status.Passed);
//throw new PendingException();
}

@Then("login page appears")
public void login_page_appears() throws ReportException {
// Write code here that turns the phrase above into concrete actions
Reporter.reportEvent("step user and pw", "Execution", Status.Passed);
Reporter.generateReport();
SDK.cleanup();
//throw new PendingException();
}

}

Once you have created all relevant steps in your cucumber / LeanFT (or Selenium) script, continue with defining the test runner class.

5.4 — Define Testrunner Class

Within the test runner class it is important to use

  • the OctaneCucumber.class in
  • attach the location of your features,
  • and glue the package for the step definition class

Here is an example.

package bdd.octane;

import org.junit.Test;
import org.junit.runner.RunWith;
import cucumber.api.CucumberOptions;
import com.hpe.alm.octane.OctaneCucumber;

@RunWith(OctaneCucumber.class)
@CucumberOptions(features = {"src/test/ressources"},
plugin = {"pretty",
"json:RunResult/cucumber.json",
"junit:RunResult/cucumber.xml",
"junit:RunResult/cucumber.html"
},
glue = {"bdd.octane"})
public class TestRunner {
@Test
public void test(){}

}

and a snapshot of this sample structure:

In the CucumberOptions glue the package name for the step definition class.

5.5 — Build your project locally

Once everthing is ready, just execute within your IDE (IntelliJ) the build job to see if all components and dependencies are configured well. If everything is fine, you should be receiving something similar as follow:

Maven should execute the feature scenario — check console of your IDE.

Make sure, that after the execution the OctaneGherkinResults.xml file is created under the folder gherkin-result on the project root.

6 — Setting up Jenkins

6.1 — Create a new MAVEN job within Jenkins

Select project type „Maven-Project“.

… then under the Build section provide the path to your pom.xml file. Make sure to select „use private maven repository”.

Provide the pom.xml and all Maven goals you want to execute

6.2 — Add build steps

We need to add now 3 build steps to move the following 3 files to the Jenkins workspace:

  • LeanFT result
  • OctaneGherkinResult.xml
  • JUnit result of the Testrunner class
To move the files, Windows batch command is required

6.3 — Add post build steps

As a last step for the Jenkins job configuration, we need to publish the result for the OctaneGherkinPlugin. Add the following to the post build step:

The OctaneGherkinResults.xml is required to update the runs in ALM Octane.

7 — Run Pipeline from Jenkins or ALM Octane

After Pipeline execution all results will be visible in ALM Octane.

8 — View Results of the Gherkin Tests in ALM Octane after Pipeline Execution

You can see after the pipeline execution that the Gherkin Test phase (automated) and coverage (passed[/failed]) have changed.

and you can see also the Gherkin Run in ALM Octane displayed containing all run informations.

Hope this article was helpful!

More information on ALM Octane BDD configuration can be found in the ALM Octane Onlinehelp: https://admhelp.microfocus.com/octane/

Enjoy!

--

--

ALM Octane

ALM Octane is a DevOps Lifecycle Management software for organizations to scale agile development from team level to the enterprise. https://embrace-devops.com