serenity-bdd-skill
Generates Serenity BDD tests in Java with Screenplay pattern, rich reporting, and Cucumber integration. Use when user mentions "Serenity", "Screenplay", "@Steps", "Serenity BDD". Triggers on: "Serenity BDD", "Screenplay pattern", "@Steps", "Serenity report".
What this skill does
# Serenity BDD Skill
## Core Patterns
### Step Library Pattern
```java
import net.serenitybdd.annotations.Step;
import net.serenitybdd.core.pages.PageObject;
public class LoginSteps extends PageObject {
@Step("Navigate to login page")
public void navigateToLogin() {
openUrl(getDriver().getCurrentUrl() + "/login");
}
@Step("Enter email: {0}")
public void enterEmail(String email) {
find(By.id("email")).sendKeys(email);
}
@Step("Enter password")
public void enterPassword(String password) {
find(By.id("password")).sendKeys(password);
}
@Step("Click login button")
public void clickLogin() {
find(By.cssSelector("button[type='submit']")).click();
}
@Step("Should see the dashboard")
public void shouldSeeDashboard() {
assertThat(getDriver().getCurrentUrl()).contains("/dashboard");
assertThat(find(By.cssSelector(".welcome")).isDisplayed()).isTrue();
}
}
```
### Test Class
```java
import net.serenitybdd.junit5.SerenityJUnit5Extension;
import net.serenitybdd.annotations.Steps;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
@ExtendWith(SerenityJUnit5Extension.class)
public class LoginTest {
@Steps LoginSteps loginSteps;
@Test
void shouldLoginWithValidCredentials() {
loginSteps.navigateToLogin();
loginSteps.enterEmail("[email protected]");
loginSteps.enterPassword("password123");
loginSteps.clickLogin();
loginSteps.shouldSeeDashboard();
}
}
```
### Screenplay Pattern
```java
import net.serenitybdd.screenplay.*;
public class Login implements Performable {
private final String email, password;
public Login(String email, String password) {
this.email = email; this.password = password;
}
@Override
public <T extends Actor> void performAs(T actor) {
actor.attemptsTo(
Enter.theValue(email).into(LoginPage.EMAIL_FIELD),
Enter.theValue(password).into(LoginPage.PASSWORD_FIELD),
Click.on(LoginPage.LOGIN_BUTTON)
);
}
public static Login withCredentials(String email, String password) {
return new Login(email, password);
}
}
// Usage
actor.attemptsTo(Login.withCredentials("[email protected]", "pass123"));
actor.should(seeThat(TheWebPage.currentUrl(), containsString("/dashboard")));
```
### Reporting
```bash
# Run tests — generates rich HTML report
mvn verify
# Report at: target/site/serenity/index.html
```
### Cloud Execution on TestMu AI
Add the `serenity-lambdatest` plugin dependency:
```xml
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-lambdatest</artifactId>
<version>${serenity.version}</version>
</dependency>
```
Configure `serenity.conf`:
```hocon
webdriver {
driver = remote
remote.url = "https://"${LT_USERNAME}":"${LT_ACCESS_KEY}"@hub.lambdatest.com/wd/hub"
}
serenity {
take.screenshots = AFTER_EACH_STEP
}
lambdatest {
build = "Serenity Build"
}
# LT:Options capabilities
"LT:Options" {
platformName = "Windows 11"
browserVersion = "latest"
visual = true
video = true
console = true
network = true
}
```
Or configure via `serenity.properties`:
```properties
webdriver.driver=remote
webdriver.remote.url=https://hub.lambdatest.com/wd/hub
lt.user=${LT_USERNAME}
lt.key=${LT_ACCESS_KEY}
lt.platform=Windows 11
lt.browserName=chrome
```
## Setup: Maven with `serenity-core`, `serenity-junit5`, `serenity-screenplay-webdriver`, `serenity-lambdatest`
## Run: `mvn verify` (generates living documentation)
## Deep Patterns
For advanced patterns, debugging guides, CI/CD integration, and best practices,
see `reference/playbook.md`.
Related in bdd-testing
reqnroll-skill
IncludedGenerates production-grade Reqnroll BDD automation scripts for web (Selenium 3/4) and mobile (Appium 2) testing in C#. Supports parallel NUnit execution locally and on TestMu AI cloud. Use when the user asks to write BDD tests, automate with Reqnroll, create .feature files, write Gherkin scenarios, write step definitions, migrate from SpecFlow, or test on browsers/Android/iOS. Triggers on: "Reqnroll", "BDD", "Gherkin", ".feature file", "step definition", "SpecFlow migration", "Selenium C#", "Appium C#", "TestMu", "LambdaTest", "NUnit BDD", "reqnroll.actions.json".
gauge-skill
IncludedGenerates Gauge test specifications in Markdown with step implementations in Java, Python, JS, or Ruby. ThoughtWorks' test automation framework. Use when user mentions "Gauge", "spec file", "## Scenario", "step implementation". Triggers on: "Gauge", "Gauge spec", "Gauge framework", "ThoughtWorks test".
specflow-skill
IncludedGenerates SpecFlow BDD tests for C#/.NET with Gherkin feature files and step bindings. Use when user mentions "SpecFlow", "C# BDD", ".NET Gherkin", "[Binding]", "[Given]/[When]/[Then]". Triggers on: "SpecFlow", "C# BDD", ".NET BDD", "step bindings", "[Binding]".
behat-skill
IncludedGenerates Behat BDD tests for PHP with Gherkin feature files and MinkContext for browser testing. Use when user mentions "Behat", "PHP BDD", "Mink", "behat.yml". Triggers on: "Behat", "PHP BDD", "Mink", "behat.yml", "FeatureContext PHP".
behave-skill
IncludedGenerates Behave BDD tests for Python with Gherkin feature files and step implementations. Use when user mentions "Behave", "Python BDD", "Python Gherkin". Triggers on: "Behave", "Python BDD", "behave test", "Python feature file".
cucumber-skill
IncludedGenerates Cucumber BDD tests with Gherkin feature files and step definitions in Java, JavaScript, or Ruby. Use when user mentions "Cucumber", "Gherkin", "Feature/Scenario", "Given/When/Then", "BDD". Triggers on: "Cucumber", "Gherkin", "BDD", "Feature file", "Given/When/Then", "step definitions".