Skip to main content

Creating New Steps

In addition to all its out-of-the-box steps, Cycle enables testers to create their own CycleScript steps with step plugins. The current "simpler" plugin architecture is available starting in Cycle 2.26. The previous "old" plugin architecture first available in Cycle 2.20 is now deprecated and no longer supported after Cycle 2.26.

The feature video below introduces plugins and demonstrates how to make them:

Why should I create new steps?

For example, suppose you need to verify that your system sends a report with very specific codes in the header. You could write procedures in CycleScript to verify them using existing web, API, or file steps, but it would be much more readable and writable to create a new step like this:

Then I see the header code "X12345" in the Special Report file

This is a domain-specific step. It uses expressive natural language to denote the desired operation declaratively, rather than using imperative language involving string parsing or complicated locators. Domain-specific steps help testers separate what must be tested behaviorally from how automation will work mechanically. They also provide living documentation for the features they cover, since anyone (developer, tester, manager, or business stakeholder) can understand them. Furthermore, they enable you to create steps for any kind of system so that your tests can be truly "end-to-end."

How do step plugins work?

New steps are provided by "step plugins." A step plugin is a local service that extends Cycle with an additional set of steps that can be called with any Given, When, or Then line in CycleScript. A plugin defines the text, parameters, and implementation for each step it provides. It also implements a standard set of endpoints defined by an OpenAPI specification so that Cycle can control the plugin during test execution and call its steps.

When Cycle runs a step in a feature file, it identifies the plugin that provides the step, makes an HTTP request to the plugin to execute the step, and receives an HTTP response once the step has completed its execution. Ultimately, steps from a step plugin should work the same as any "regular" Cycle steps. They should be effectively indistinguishable in a feature file.

How do I create a step plugin?

Cycle Labs provides an SDK for developing step plugins in Java. It provides all the boilerplate code for the service and API aspects of the plugin. You will need to write the step specs that define how to call the steps along with step definition classes that perform the steps. In this sense, developing a plugin is similar to developing a Cucumber test project. Cycle Labs also provides support for developing plugins in the Cycle Testing VS Code Extension.

Java is presently the only language for which Cycle Labs provides a plugin SDK. Cycle runs Java 21 and supports plugins running Java 21. Please let us know if you would like to develop plugins in other programming languages.

How do I plug my plugin into Cycle?

Step plugins are installed into Cycle's installation directory together with some required settings. Cycle will automatically identify and use step plugins that are properly configured, and it will yield errors whenever it discovers problems with step plugins.

Who can create a step plugin?

Any Cycle user with intermediate-level Java programming skills can create a step plugin. The target persona for a plugin developer is a test automation engineer who is familiar with BDD test frameworks. A plugin author does not need to be a full stack developer. They do not need to know how to build a web service or an API themselves because the plugin SDK will handle those details.

How do I get started?

If you want to dive right into code, check out the example plugin project.

Otherwise, for a step-by-step guide, please read the following pages in order:

  1. Compare alternative solutions to make sure that a step plugin is the right approach.
  2. Determine the new steps to create.
  3. Create the plugin project.
  4. Write the step specs.
  5. Implement the step definitions for those steps.
  6. Access Cycle settings from steps.
  7. Implement fixtures for setup and cleanup routines.
  8. Call steps in other plugins if necessary.
  9. Test the steps.
  10. Add the plugin to Cycle.
  11. Resolve any plugin errors.
  12. Understand the plugin lifecycle as Cycle runs tests.

If your step plugin will contain several steps, then it may be best to implement steps in small batches. Implement a few steps at a time, plug the latest build into Cycle, and test the steps iteratively.