BDD Testing

Behavior-Driven Development

When adding new features, it is good to start by asking the question "What value is provided to the user?" More specifically, we're starting with "Why?" for a given "Who" before talking about the "What".

The format used:

As a <specific-role>,
I want to <take some action>,
So I can <receive some benefit>.

This turns into Features and Use Case Scenarios which are documented as BDD Test Suites and Scenarios. This English-based Cucumber/Gherkin language is mapped to Selenium scripts driven by Python to interact with a browser-based (Chrome in our case) front-end. This front-end is generally stood up in a development environment that can respond to live changes in either the front-end or the back-end.

Using Ionic, mobile apps can be run as Single-Page Applications (SPA) for development and testing.

Components for Behavior-Driven Development and Testing

  • PyCharm is the development IDE for the Behave / Cucumber / Gherkin environment.
  • ionic serve is the tool that stands up a live server for the SPA; browsers (and browser drivers) connect directly to the ionic server.
  • XHR requests from the browser (under the SPA control) are made directly to the back-end REST API. This is currently the WildFly container.
  • For looking at the REST API, Postman is convenient to use.

Ionic Serve

The command that has been useful:

ionic serve --no-open -c
  • —no-open avoids taking the time to create a new browser tab opened to the application. The BDD tools will open a separate window anyway.
  • -c routes console messages from the SPA to the stdout where the ionic server is being run. This makes it convenient to see the SPA's logging.

TIP: when the ECONNRESET problem occurs, things sometimes work better when you run in debug mode.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License