bdd-dsl

Logo

Metamodels and associated toolings for applying Behaviour-Driven Development (BDD) to test robotic scenarios.

View the Project on GitHub secorolab/bdd-dsl

Metamodels for Specifying BDD Scenarios in Robotics

Background

Behaviour-Driven Development (BDD)

Requirements in Test-Driven Development (TDD) are often represented using User Stories, typically in the following format:

As a [Stakeholder role]
I want [Feature]
So that [Benefit]

In his original blog post1 introducing BDD, North proposed to represent AC for each user story as a list of scenarios capturing the expected behaviours of the system, each using the following formulation:

Given [Precondition]
When [Event/Action]
Then [Expected Outcome]

This formulation extends user stories with narratives, each consist of initial condition(s), events or actions that signal the start of the behaviour, and the criteria that characterizes what constitute a successful behaviour. We consider the Given-When-Then formulation a good metamodel because of its simple concepts, which are both easy to understand and flexible to different interpretations and extensions. Furthermore, BDD approaches, e.g. with the popular Gherkin syntax, has wide support in the software engineering community for test automation in many program languages and frameworks. This can reduce the effort in generating executable implementations for verifying BDD AC in the future.

AC in robotic competitions & benchmarks

A challenge of applying BDD to any complex domains is to deal with the myriad variations that may exist for the same scenario. Alferez et al.2 proposed to define scenario templates for common system behaviours, e.g. in their use case for operations on different data structures. Concrete BDD scenarios can then be generated from these templates depending on the particular data object being tested.

Rulebook feature model
Fig. 1: A Feature Model of Robotic Competitions

We aim to apply a similar idea for representing robotic scenarios, whose variability dimensions can be vastly more numerous and complex compared to the application investigated by Alferez et al.2. To this end, we analysed rulebooks from several robotic benchmarks and competitions3 to identify common elements used to describe test scenarios at these events. We consolidate our findings is a Feature Model, shown in Fig. 1. This serves as the basis for designing a metamodel, i.e., model of model, for BDD robotic scenarios, as shown in Fig. 2

Conceptualizing Robotic Acceptance Criteria (AC)

BDD meta-model concepts
Fig. 2: A metamodel to specify BDD scenarios in robotics

Example: modelling a pick-and-place scenario

To help with understanding the design of our MM, let’s start with a BDD specification for a simple pick & place application. Below is a potential Gherkin feature for this example, where the scenario is split into two phases for object picking and placing:

Feature: Object pick and place

  Scenario Outline: Object pickup
    Given "<object>" is located at "<pick_ws>"
    When "<robot>" picks up "<object>"
    Then "<object>" is held by "<robot>"
    Examples:
      |object|pick_ws|robot|
      |...|...|...|

  Scenario Outline: Object placing
    Given "<object>" is held by "<robot>"
    When "<robot>" places "<object>" at "<place_ws>"
    Then "<object>" is located at "<place_ws>"
    Examples:
      |object|robot|place_ws|
      |...|...|...|

Issues with Gherkin & current BDD frameworks, including implicit timing information & limited flexibility in coordinating scenario execution, are discussed at length in 3. Here, we use this example to help explaining the design of our metamodels in the following sections.

Clauses as fluents

Current BDD approaches generally do not support specifying when scenario clauses should hold true. For instance, the “is held by” clause in the Gherkin example above asserts that the robot holds the target object after completing the pickup behaviour. The same assertion must hold before the placing behaviour in the second scenario. To capture temporal element in BDD clauses, we model them using the fluent concept, i.e., time varying properties of the world 4. A fluent includes a predicate asserting a property of interest and a term indicating when the assertion should be valid. Different formalisms of dynamic logic diverge mainly in how to represent the temporal term.

Pick & place example model - Fluents
Fig. 3: Modelling BDD clauses as fluents

Fig. 3 shows an example of how we apply the fluent concept to model BDD clauses. Key design points:

Variation and Scene

Fig. 1 lists objects, workspaces & agents as part of scenario specification. These elements may vary between variations of a scenario (possible in Gherkin via the Examples table). A scenario specification may also include invariant elements, e.g., for specifying grasping from cluster tasks or furnitures that remain unchanged.

Pick example model - Scene & task variation
Fig. 4: Modelling varying & invariant elements in a BDD scenario

Therefore, we introduce in our metamodel the Scene & TaskVariation concepts for specifying invariant & varying elements, respectively. An example of this design is shown in Fig. 4. Key design points:

Scenario Template, Variant, & User Story

Pick example model - composition
Fig. 5: Modelling BDD scenario template, variant & user story

Our metamodel includes two composites to represent concrete BDD scenarios, namely ScenarioTemplate and ScenarioVariant. UserStory is then a composite of scenario variants. Key design points:

Representing Robotic AC as Knowledge Graphs

We choose to represent our metamodels and models for specifying BDD scenarios with the JSON-LD Schema. The JSON-LD representation of the BDD metamodel described here can be found on our metamodels page, and the corresponding models on the models page. Notable models:

Model Description
pickplace.tmpl.json JSON-LD model for a pick & place scenario template
pickplace-secorolab-isaac.var.json JSON-LD model for variants of the above template
secorolab-env.scene.json JSON-LD model of scenes used in the above scenario variants
secorolab.env.json JSON-LD model for the environment elements used in the scenes & scenario variants above

For an overview of main JSON-LD keywords used in our models, please take a look at our modelling tutorial. More details on this standard can be found on the official online documentation.

References

  1. D. North, “Behavior Modification: The evolution of behaviour-driven development”, Better Software, 2006. 

  2. M. Alferez, F. Pastore, M. Sabetzadeh, et al., “Bridging the Gap between Requirements Modeling and Behavior-Driven Development,” 22nd MODELS, 2019, doi: 10.1109/MODELS.2019.00008 2

  3. M. Nguyen, N. Hochgeschwender, S. Wrede, “An analysis of behaviour-driven requirement specification for robotic competitions”, 5th International Workshop on Robotics Software Engineering (RoSE’23), May 2023.  2

  4. R. Miller and M. Shanahan, “Some Alternative Formulations of the Event Calculus,” in Comp. Logic: Logic Programming and Beyond, vol. 2408, 2002, pp. 452–490, doi: 10.1007/3-540-45632-5_17