# TestFly Part 5: BDD testing with Cucumber 7, BaseCucumberSteps and @retryable tags

URL: https://hakangul.lovable.app/blog/testfly-part-5-bdd-cucumber-7-integration-enterprise-testing
Author: Hakan Gül — Team Lead Senior Test Automation Engineer
Published: 2026-08-28
Updated: 2026-10-18
Category: test-automation
Tags: TestFly, Cucumber, BDD, BaseCucumberTest, BaseCucumberSteps, Retryable, Java, SDET

> How TestFly works with Cucumber 7: the BaseCucumberTest runner, BaseCucumberSteps helpers, CucumberStepLogger reporting and per-scenario @retryable tags.

## English

## BDD with Cucumber 7 in TestFly

TestFly works with Cucumber 7 without extra boilerplate. `CucumberHooks` in `io.testfly.cucumber` manages the driver lifecycle, and `CucumberStepLogger` streams a step timeline straight into the HTML report. When a scenario fails, TestFly captures a screenshot and embeds it in both reports. To retry a single scenario, tag it with `@retryable` or `@retryable=N`.

## Runner class (`BaseCucumberTest`)

The runner extends `BaseCucumberTest`. Add `io.testfly.cucumber` to the glue path and register `CucumberStepLogger` as a plugin.

```java
package com.yourcompany.bdd;

import io.cucumber.testng.CucumberOptions;
import io.testfly.cucumber.BaseCucumberTest;

@CucumberOptions(
    features = "src/test/resources/features",
    glue     = {"com.yourcompany.bdd.steps", "io.testfly.cucumber"},
    plugin   = {"pretty", "io.testfly.cucumber.CucumberStepLogger"}
)
public class CucumberRunner extends BaseCucumberTest {}
```

## Step definitions with `BaseCucumberSteps`

Step classes extend `BaseCucumberSteps` and call its helpers (`open`, `find`, `assertThat`) directly. The `assertThat` check retries on its own until the condition holds.

```java
package com.yourcompany.bdd.steps;

import io.cucumber.java.en.Given;
import io.cucumber.java.en.When;
import io.cucumber.java.en.Then;
import io.testfly.cucumber.BaseCucumberSteps;
import org.openqa.selenium.By;

public class LoginSteps extends BaseCucumberSteps {

    @Given("the user is on the login page")
    public void onLoginPage() {
        open("/login");
    }

    @When("they login as {string} with password {string}")
    public void login(String username, String password) {
        find(By.id("username")).type(username);
        find(By.id("password")).type(password);
        find(By.id("submit")).click();
    }

    @Then("the dashboard is visible")
    public void dashboardVisible() {
        assertThat(By.id("dashboard")).isVisible(); // auto-retrying assertion
    }
}
```

## Per-scenario retry tag

Put the tag on the scenario you want retried:

```gherkin
@retryable=2
Scenario: Flaky payment gateway widget
  Given the user is on the payment screen
  When they submit payment details
  Then the transaction should be confirmed
```

## Türkçe

## TestFly ile Cucumber 7

TestFly, Cucumber 7 ile ek bir kurulum kodu yazmadan çalışır. Sürücünün açılıp kapanmasını `io.testfly.cucumber.CucumberHooks` yönetir. `CucumberStepLogger` adımların zaman çizelgesini doğrudan HTML raporuna yazar. Hata anında ekran görüntüsü alınır ve rapora eklenir. Tek bir senaryoyu yeniden denemek için `@retryable` ya da `@retryable=N` etiketini kullanabilirsiniz.

## Runner sınıfı (`BaseCucumberTest`)

Runner sınıfı `BaseCucumberTest` sınıfından türer. Glue yoluna `io.testfly.cucumber` paketini, plugin listesine de `CucumberStepLogger` sınıfını eklemeniz yeterli.

```java
package com.yourcompany.bdd;

import io.cucumber.testng.CucumberOptions;
import io.testfly.cucumber.BaseCucumberTest;

@CucumberOptions(
    features = "src/test/resources/features",
    glue     = {"com.yourcompany.bdd.steps", "io.testfly.cucumber"},
    plugin   = {"pretty", "io.testfly.cucumber.CucumberStepLogger"}
)
public class CucumberRunner extends BaseCucumberTest {}
```

## `BaseCucumberSteps` ile adım tanımları

Adım sınıfları `BaseCucumberSteps` sınıfından türer; `open`, `find` ve `assertThat` gibi yardımcıları doğrudan çağırır. `assertThat` koşul sağlanana kadar kendisi bekler.

```java
package com.yourcompany.bdd.steps;

import io.cucumber.java.tr.Diyelimki;
import io.cucumber.java.tr.Eğer;
import io.cucumber.java.tr.O_zaman;
import io.testfly.cucumber.BaseCucumberSteps;
import org.openqa.selenium.By;

public class LoginAdimlari extends BaseCucumberSteps {

    @Diyelimki("kullanıcı giriş sayfasındadır")
    public void girisSayfasinda() {
        open("/login");
    }

    @Eğer("kullanıcı adı {string} ve şifre {string} ile giriş yaparsa")
    public void girisYap(String username, String password) {
        find(By.id("username")).type(username);
        find(By.id("password")).type(password);
        find(By.id("submit")).click();
    }

    @O_zaman("dashboard ekranı görünür olmalıdır")
    public void dashboardGorunur() {
        assertThat(By.id("dashboard")).isVisible(); // otomatik bekleyen doğrulama
    }
}
```

## Senaryo bazında retry etiketi

Etiketi, yeniden denenmesini istediğiniz senaryonun üstüne yazın:

```gherkin
@retryable=2
Senaryo: Dış ödeme servis entegrasyonu
  Diyelim ki kullanıcı ödeme ekranındadır
  Eğer geçerli kart bilgileri girilirse
  O zaman ödeme onay kodu ekranda görünmelidir
```
