Hackathon 0x1 – Interactive mode in Behave

Presentation of the Project

As testers, we spend a lot of time working on behave, our test automation framework ((behave is a clone of cucumber written in Python. It is based on the BDD (Behavior Driven Development) principles. Tests are described as a succession of english-sentences (assumptions, then actions, then results) which are themselves mapped to the corresponding Python code.)). Our test framework is a great tool, but it takes a lot of time starting and initializing the product, running tests one by one.

We are not only test automation developers. We also need to explore the product under test by experimenting again and again based on the information we gather along the way. Manual testing is the basic approach to perform non-trivial experiments, but it can benefit from automated testing as it offers a quick and reliable way to set up a product in any given state.

The hackathon ((a hackathon is an event in which computer programmers and others involved in software development, including graphic designers, interface designers and project managers, collaborate intensively on software projects. Intersec promotes this event to focus and enhance project innovation)) was the perfect opportunity to buy ourselves a new exploratory tool to perform interactive automated testing. To do that, we needed to be able to:

  • Gain more control over the set up steps
  • Pause the product in order to manually test the state of the product
  • Select some more steps to run, check again, and so on
  • Explore with some automatic help

We elaborated an interactive mode to manage the run of a scenario. The goal was to be able to play each sentence on demand. This mode would help us in the future to reproduce issues and to set up the environment faster for testing purpose or even for customer demonstration.

Technical description

The first need was to implement a prompt. Indeed, without an interactive prompt no input can be received. We opted for the ncurses library to write a text-based user interface in a terminal-agnostic manner.

We actually wanted an interactive and simple interface that:

  • Manages a complete event loop;
  • Is easy to integrate in Linux shells;
  • Has an good interface manager;
  • Eases windows split and dimension change.

The main difficulty was to handle keyboard input as a simple text editor:

Prompt presentation

Prompt presentation

The second step was to cleanly plug this prompt in behave‘s environment. We chose to add an option to handle this use case. In order to create the interactive mode in behave, we just needed to overload two base classes (Runner and Scenario). Those modifications did not break any former behavior, which ensured backward-compatibility.

To improve the usability of our tests tools, we deployed a help listing the available sentences with or without a defined keyword.

Test help function

Test help function

The third step was to get a complete functional workflow. Indeed as seen in the previous steps, the prompt is able to send to behave‘s environment a partial or a complete sentence in order to perform a match. Once the match is done, we must allow the user to play the desired step:

Complete workflow

Complete workflow

With this last step our goal is now reached with a working proof of concept.


During the 2 days of the Hackathon, we were able to:

  • Update our test tool to start a product and keep its context;
  • Build a shell with ncurses, to allow typing existing sentences;
  • Provide a help for all available sentences.

Other ideas were mentioned during the conception of our project:

  • Allow starting the product with predefined context (be able to select a set of sentences);
  • Develop an interface to select the sentences;
  • Allow using our tools in debugger mode.

The BHV Team: Camille P., Cyrielle M., Marion B., Nicolas G.