Overview
The Makers BTG Tests framework follows a standard Maven/Gradle project structure with clear separation between production code, test code, and resources.This structure follows Java and Gradle conventions, making it familiar to developers and compatible with most IDEs.
Directory Layout
Source Directories
src/main/java/
Contains production code (currently minimal):The main source directory is reserved for utility classes, helpers, or shared code that’s not test-specific. Most automation code lives in
src/test/java/.src/test/java/
Contains all test automation code:Key Directories Explained
runners/
Purpose: Contains test runner classes that configure and execute tests Location:src/test/java/org/btg/practual/runners/
Example:
stepDefinitions/
Purpose: Contains Cucumber step definition classes that link Gherkin steps to Java code Location:src/test/java/org/btg/practual/stepDefinitions/
Current file: GeneracionReporteSteps.java
Step Definition Best Practices
Step Definition Best Practices
- One class per feature: Create
LoginSteps.java,ReportGenerationSteps.java, etc. - Descriptive names: Use names that clearly indicate which feature they support
- Shared steps: Common steps (login, navigation) can be in a
CommonSteps.javafile - Spanish annotations: This project uses Spanish Gherkin keywords (
@Dado,@Cuando,@Entonces)
features/
Purpose: Contains Cucumber feature files written in Gherkin syntax Location:src/test/resources/features/
Current file: GeneracionReporte.feature
Feature Organization
Group related scenarios in the same feature fileExamples:
Login.featureReportGeneration.featureUserManagement.feature
Subdirectories
Create subdirectories for large projects:
features/authentication/features/reports/features/admin/
Configuration Files
build.gradle
Purpose: Defines project dependencies, plugins, and build tasks Location: Project root Key sections:Modify
build.gradle when:- Adding new dependencies (e.g., REST Assured for API testing)
- Updating Serenity or other library versions
- Configuring new Gradle tasks
- Changing report generation settings
serenity.conf
Purpose: Runtime configuration for Serenity BDD and WebDriver Location:src/test/resources/serenity.conf
Key sections:
Build Output (target/)
Generated during test execution (not committed to version control):Always add
target/ to .gitignore to avoid committing build artifacts to version control.Adding New Files
Adding a New Feature File
- Create the file in
src/test/resources/features/ - Use the
.featureextension - Start with
#language:esfor Spanish Gherkin - Add feature description and scenarios with appropriate tags
Adding New Step Definitions
- Create a new class in
src/test/java/org/btg/practual/stepDefinitions/ - Use a descriptive name ending with
Steps.java - Import Cucumber annotations:
io.cucumber.java.es.* - Implement step methods with
@Dado,@Cuando,@Entoncesannotations
Adding Screenplay Components
As you implement the Screenplay pattern, organize code in these directories:Package Structure
All code follows the base package:org.btg.practual
Recommended subpackages:
| Package | Purpose | Example Classes |
|---|---|---|
runners | Test runners | CucumberRunner, SmokeTestRunner |
stepDefinitions | Cucumber glue code | LoginSteps, ReportSteps |
tasks | Screenplay tasks | Login, GenerateReport |
questions | Screenplay questions | ReportStatus, LoginResult |
pages | Page object targets | ChronosHomePage, LoginPage |
models | Data models | ReportData, UserCredentials |
utils | Utilities and helpers | DateHelper, DataGenerator |
Configuration Properties
Gradle Wrapper
Location:gradle/wrapper/gradle-wrapper.properties
Purpose: Defines Gradle version for consistent builds
Always use the Gradle wrapper (
./gradlew) instead of a locally installed Gradle to ensure consistent builds across environments.Settings
Location:settings.gradle
Purpose: Defines root project name
Best Practices
Follow Package Conventions
Keep all code under
org.btg.practual for consistencyOrganize by Feature
Group related feature files, step definitions, and page objects together
Use Descriptive Names
File and class names should clearly indicate their purpose
Keep Tests in src/test/
All test code belongs in
src/test/, not src/main/Version Control
Commit source files, ignore
target/ and build outputsIDE Compatibility
Structure works with IntelliJ, Eclipse, and VS Code
IDE Setup
IntelliJ IDEA
- Open project:
File > Open > Select build.gradle - IntelliJ auto-detects Gradle and imports dependencies
- Mark
src/test/javaas Test Sources (usually automatic) - Mark
src/test/resourcesas Test Resources - Install Cucumber for Java plugin for feature file support
VS Code
- Install extensions:
- Extension Pack for Java
- Cucumber (Gherkin) Full Support
- Gradle for Java
- Open project folder
- VS Code detects Gradle and configures the project
For more architectural details, see Framework Architecture. To understand Serenity configuration, visit Serenity BDD Integration.
Quick Reference
| Task | Command |
|---|---|
| Run all tests | ./gradlew test |
| Run with tag filter | ./gradlew test -Dcucumber.filter.tags="@smoke" |
| Run specific environment | ./gradlew test -Denvironment=qa |
| Generate reports only | ./gradlew aggregate |
| Clean build directory | ./gradlew clean |
| View dependencies | ./gradlew dependencies |
| Build without tests | ./gradlew build -x test |