How charlyautomatiza/starter-karate-dsl works
Main Components of the System
• API Test Suite – The core of the project where all API tests are defined.
• REST API tests: Located under src/test/java/examples/users with the feature file (users.feature) and its associated runner (UsersRunner.java).
• GraphQL API tests: Located under src/test/java/examples/usersgql with the feature file (users-gql.feature), associated queries (e.g., user-by-id.graphql), and runner (UsersGqlRunner.java).
• Additional examples/test files: Such as ExamplesTest.java for generic examples.
• Configuration & Setup:
• karate-config.js: Contains global configuration for Karate tests.
• logback-test.xml: Provides logging configuration.
• pom.xml: Maven build configuration including dependencies and build plugins necessary for the execution of tests.
• CI/CD Integration:
• GitHub Workflows: .github/workflows/karate-test-runner.yml to trigger tests on pushes.
• JUnit Report actions on the marketplace, as referenced in the README.
• Reporting:
• Test execution generates HTML reports in target/karate-reports (even though the target folder isn’t shown, it’s generated at runtime).
Relationships and Interactions
• Test Runner -> Feature Files: Runners (e.g., UsersRunner.java, UsersGqlRunner.java) are responsible for invoking the execution of the corresponding feature files.
• Feature Files -> API Endpoints: The feature files contain scenarios that target external API endpoints (REST or GraphQL), though these endpoints are not hosted within the project.
• Configuration -> Tests: karate-config.js and logback-test.xml are used to set up the testing environment and logging.
• Maven Lifecycle -> Execution & Reporting: The pom.xml drives compilation, test execution (via mvn clean test), and report generation.
• GitHub Actions -> CI Test Pipeline: When a push event occurs, .github/workflows/karate-test-runner.yml triggers the Maven commands on the remote environment and subsequently builds reports of the test runs.
Architectural Patterns and Design Principles
• Separation of Concerns: The project clearly separates test definitions (feature files), test runners, configuration files, and CI/CD workflows.
• Convention over Configuration: Following Karate DSL conventions for directory structure and naming, making it easy to locate and modify tests.
• Automation & Reporting: Built-in support for automatic test execution and unified reports, aiding in continuous integration practices.
Relevant Technologies, Frameworks, and Tools
• Karate DSL: The primary framework used for writing and executing API tests (both REST and GraphQL).
• Maven: Manages dependency, build lifecycle, and runs tests.
• Java JDK (version 17 is required): For running the test automation framework.
• GitHub Actions: For CI/CD automation.
• JUnit and Report Generation Tools: For generating structured test reports.