Symphony Bot Cucumber Tests

Behavioural-driven testing framework for the Symphony API Client

License

License

Categories

Categories

Java Languages Cucumber Application Testing & Monitoring ORM Data
GroupId

GroupId

com.symphony.platformsolutions
ArtifactId

ArtifactId

symphony-bot-cucumber-tests-java
Last Version

Last Version

0.4
Release Date

Release Date

Type

Type

jar
Description

Description

Symphony Bot Cucumber Tests
Behavioural-driven testing framework for the Symphony API Client
Project URL

Project URL

https://github.com/SymphonyPlatformSolutions/symphony-bot-cucumber-tests
Source Code Management

Source Code Management

https://github.com/SymphonyPlatformSolutions/symphony-bot-cucumber-tests-java

Download symphony-bot-cucumber-tests-java

How to add to project

<!-- https://jarcasting.com/artifacts/com.symphony.platformsolutions/symphony-bot-cucumber-tests-java/ -->
<dependency>
    <groupId>com.symphony.platformsolutions</groupId>
    <artifactId>symphony-bot-cucumber-tests-java</artifactId>
    <version>0.4</version>
</dependency>
// https://jarcasting.com/artifacts/com.symphony.platformsolutions/symphony-bot-cucumber-tests-java/
implementation 'com.symphony.platformsolutions:symphony-bot-cucumber-tests-java:0.4'
// https://jarcasting.com/artifacts/com.symphony.platformsolutions/symphony-bot-cucumber-tests-java/
implementation ("com.symphony.platformsolutions:symphony-bot-cucumber-tests-java:0.4")
'com.symphony.platformsolutions:symphony-bot-cucumber-tests-java:jar:0.4'
<dependency org="com.symphony.platformsolutions" name="symphony-bot-cucumber-tests-java" rev="0.4">
  <artifact name="symphony-bot-cucumber-tests-java" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.symphony.platformsolutions', module='symphony-bot-cucumber-tests-java', version='0.4')
)
libraryDependencies += "com.symphony.platformsolutions" % "symphony-bot-cucumber-tests-java" % "0.4"
[com.symphony.platformsolutions/symphony-bot-cucumber-tests-java "0.4"]

Dependencies

compile (6)

Group / Artifact Type Version
com.symphony.platformsolutions : symphony-api-client-java jar 1.0.48
io.cucumber : cucumber-java8 jar 4.8.0
io.cucumber : cucumber-junit jar 4.8.0
org.mockito : mockito-junit-jupiter jar 3.2.4
org.reflections : reflections jar 0.9.11
org.junit.jupiter : junit-jupiter-api jar 5.5.2

Project Modules

There are no modules declared in this project.

Symphony Bot Cucumber Tests

Maven Central License: MIT Email

This project aims to provide Symphony bot developers with a foundation to write end-to-end behavioural tests using Cucumber

Installation

Maven

<dependency>
    <groupId>com.symphony.platformsolutions</groupId>
    <artifactId>symphony-bot-cucumber-tests</artifactId>
    <version>[0,)</version>
</dependency>

Gradle

compile: 'com.symphony.platformsolutions:symphony-bot-cucumber-tests:0.+'

Requirements

  • Project built on the Symphony Client Library SDK (symphony-api-client-java)
  • Cucumber plugin for your IDE

Writing a Test

  • Cucumber tests have two parts:
    • Features (in English)
    • Step Definitions (in code)

This project provides a number of basic step definitions to simulate Symphony-related activity with a bot

Example Feature

Feature: Basic Commands

  Scenario: Say hello
    Given a Symphony user types "hello"
    When a Symphony user sends the message in a room
    Then The bot should display the following response
      """
      Hi there!
      """

Supported Steps

  • Given..
    • the stream id is {string}
    • a Symphony user types {string}
    • there is a form with id {string}
    • a Symphony user types {string} into the {string} text field
    • a Symphony user checks {string} for the {string} checkbox
    • a Symphony user chooses {string} for the {string} radio button
    • a Symphony user chooses {string} for the {string} dropdown box
    • a Symphony user chooses these values for the {string} person selector
    • a Symphony user attaches a file named {string}
    • the user is an owner of the room
    • the user is not an owner of the room
  • When..
    • a Symphony user sends the message in an IM
    • a Symphony user sends the message in a room
    • a Symphony user submits the form using the {string} button
  • Then..
    • The bot should display the following response
    • The bot's response should contain
    • The bot's response should contain {string}
    • The bot should send the following response data
    • The bot's response data should contain {string}
    • The bot should send an attachment named {string}

Adding Features and Step Definitions

You should continue to add features and step definitions to test custom logic specific to your bot.

Feature File

Feature: Bot Friends

  Scenario: Respond to friends
    Given a Symphony user types "are we friends?"
      And the user is a friend
    When a Symphony user sends the message in an IM
    Then The bot should display the following response
      """
      Hello friend!
      """

Step Definitions File

public class MyBotStepDefinitions implements En {
    public MyBotStepDefinitions() {
        Given("the user is a friend", () -> {
            FriendService.addFriend(SymStepDefinitions.getSampleUser().getUserId());
        });
    }
}

Implementation

There are two options for implementation:

  • SymBotClient injection
    • In your listener implementations, add a constructor with a single SymBotClient parameter
    • Use that SymBotClient instance for all calls
  • Static
    • Make your main class implement SymStaticMain
    • Add a constructor with a single SymBotClient parameter
    • Override the getBotClient() method to return the shared SymBotClient instance

IDE Configuration

  • In the respective launch configuration for the feature, set the Glue as:
    • com.symphony.ps.sdk.bdd
    • Your own package containing your custom Step Definitions
com.symphony.platformsolutions

Symphony Platform Solutions

Symphony supported software client, bots, apps, and examples.

Versions

Version
0.4
0.3
0.2
0.1