gradle-testing-setup
Configures comprehensive testing in Gradle including JUnit 5, TestContainers, test separation (unit vs integration), and code coverage with JaCoCo. Use when asked to "set up JUnit 5", "configure TestContainers", "separate integration tests", or "add code coverage". Works with build.gradle.kts, test source sets, and CI/CD configurations.
What this skill does
# Gradle Testing Setup
## Table of Contents
- [When to Use This Skill](#when-to-use-this-skill)
- [Quick Start](#quick-start)
- [Instructions](#instructions)
- [Examples](#examples)
- [Commands Reference](#commands-reference)
- [See Also](#see-also)
## When to Use This Skill
Use this skill when you need to:
- Set up JUnit 5 (Jupiter) testing framework
- Configure TestContainers for integration tests with real databases
- Separate unit tests from integration tests
- Measure code coverage with JaCoCo
- Enforce minimum code coverage thresholds
- Configure parallel test execution for faster test runs
- Set up test logging and reporting in CI/CD
- Create separate source sets for integration tests
## Quick Start
Add to `build.gradle.kts`:
```kotlin
dependencies {
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation("org.testcontainers:testcontainers:1.21.0")
testImplementation("org.testcontainers:junit-jupiter:1.21.0")
testImplementation("org.testcontainers:postgresql:1.21.0")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
plugins {
id("jacoco")
}
tasks.test {
useJUnitPlatform()
}
tasks.jacocoTestReport {
dependsOn(tasks.test)
finalizedBy(tasks.jacocoTestCoverageVerification)
}
tasks.check {
dependsOn(tasks.jacocoTestReport)
}
```
Run tests:
```bash
./gradlew test # Run unit tests
./gradlew test jacocoTestReport # With coverage report
./gradlew integrationTest # Run integration tests (if configured)
```
## Instructions
### Step 1: Configure JUnit 5 (Jupiter)
Add JUnit 5 dependencies:
```kotlin
dependencies {
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.junit.jupiter:junit-jupiter:5.11.0")
testRuntimeOnly("org.junit.platform:junit-platform-launcher:1.11.0")
}
tasks.test {
useJUnitPlatform()
}
```
**Advanced JUnit 5 configuration**:
```kotlin
tasks.test {
useJUnitPlatform {
// Include/exclude tags
includeTags("unit", "integration")
excludeTags("slow", "manual")
// Include/exclude by engine
includeEngines("junit-jupiter")
excludeEngines("junit-vintage")
}
// Filter tests by pattern
filter {
includeTestsMatching("*Test")
includeTestsMatching("*Tests")
excludeTestsMatching("*IntegrationTest")
}
// Parallel test execution
maxParallelForks = Runtime.getRuntime().availableProcessors() / 2
// System properties for tests
systemProperty("junit.jupiter.execution.parallel.enabled", "true")
systemProperty("junit.jupiter.execution.parallel.mode.default", "concurrent")
// Detailed logging
testLogging {
events("passed", "skipped", "failed", "standardOut")
showExceptions = true
showStackTraces = true
showCauses = true
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
}
}
```
### Step 2: Set Up TestContainers for Integration Tests
Add TestContainers dependencies:
```kotlin
dependencies {
testImplementation("org.testcontainers:testcontainers:1.21.0")
testImplementation("org.testcontainers:junit-jupiter:1.21.0")
testImplementation("org.testcontainers:postgresql:1.21.0")
testImplementation("org.testcontainers:gcloud:1.21.0") // For Pub/Sub emulator
}
tasks.test {
useJUnitPlatform()
// Docker socket configuration
systemProperty("testcontainers.reuse.enable", "true")
}
```
**Example integration test with TestContainers**:
```java
@SpringBootTest
@Testcontainers
class SupplierChargesIntegrationTest {
@Container
static PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:15")
.withDatabaseName("testdb")
.withUsername("test")
.withPassword("test");
@Container
static GenericContainer<?> pubsub = new GenericContainer<>("google/cloud-sdk:emulators")
.withExposedPorts(8085)
.withCommand("gcloud", "beta", "emulators", "pubsub", "start", "--host-port=0.0.0.0:8085");
@DynamicPropertySource
static void configureProperties(DynamicPropertyRegistry registry) {
registry.add("spring.datasource.url", postgres::getJdbcUrl);
registry.add("spring.datasource.username", postgres::getUsername);
registry.add("spring.datasource.password", postgres::getPassword);
registry.add("spring.cloud.gcp.pubsub.emulator-host",
() -> "localhost:" + pubsub.getMappedPort(8085));
}
@Test
void testDatabaseAndPubSub() {
// Test with real PostgreSQL and Pub/Sub emulator
}
}
```
### Step 3: Separate Unit and Integration Tests
Create separate source sets and tasks:
```kotlin
sourceSets {
create("integrationTest") {
java {
srcDir("src/integrationTest/java")
compileClasspath += sourceSets.main.get().output + sourceSets.test.get().output
runtimeClasspath += sourceSets.main.get().output + sourceSets.test.get().output
}
resources {
srcDir("src/integrationTest/resources")
}
}
}
// Create integration test task
val integrationTest = tasks.register<Test>("integrationTest") {
description = "Run integration tests"
group = "verification"
testClassesDirs = sourceSets["integrationTest"].output.classesDirs
classpath = sourceSets["integrationTest"].runtimeClasspath
useJUnitPlatform()
// Run after unit tests
shouldRunAfter(tasks.test)
// Logging
testLogging {
events("passed", "skipped", "failed")
}
}
// Include integration tests in overall check
tasks.check {
dependsOn(integrationTest)
}
```
**Directory structure**:
```
src/
├── main/
│ └── java/
├── test/ # Unit tests
│ ├── java/
│ │ └── com/example/
│ │ ├── ServiceTest.java
│ │ └── ControllerTest.java
│ └── resources/
│ └── application-test.yml
└── integrationTest/ # Integration tests
├── java/
│ └── com/example/
│ └── ServiceIntegrationTest.java
└── resources/
└── application-integration.yml
```
### Step 4: Configure Code Coverage with JaCoCo
Add JaCoCo plugin and configuration:
```kotlin
plugins {
id("jacoco")
}
jacoco {
toolVersion = "0.8.12"
}
tasks.jacocoTestReport {
dependsOn(tasks.test)
reports {
xml.required = true
html.required = true
csv.required = false
xml.outputLocation = layout.buildDirectory.file("reports/jacoco/test/jacocoTestReport.xml")
html.outputLocation = layout.buildDirectory.dir("reports/jacoco/test/html")
}
finalizedBy(tasks.jacocoTestCoverageVerification)
}
// Enforce coverage minimums
tasks.jacocoTestCoverageVerification {
violationRules {
// Overall coverage requirement
rule {
element = "BUNDLE"
limit {
minimum = BigDecimal("0.60") // 60% minimum
}
}
// Class-level requirements
rule {
element = "CLASS"
excludes = listOf("**/config/*", "**/dto/*")
limit {
counter = "LINE"
value = "COVEREDRATIO"
minimum = BigDecimal("0.50") // 50% per class
}
}
// Method-level requirements
rule {
element = "METHOD"
limit {
counter = "LINE"
value = "COVEREDRATIO"
minimum = BigDecimal("0.40") // 40% per method
}
}
}
}
// Generate report after tests
tasks.test {
finalizedBy(tasks.jacocoTestReport)
}
// Include in overall check
tasks.check {
dependsOn(tasks.jacocoTestReport)
}
```
### Step 5: Configure Test Logging
Use prettier test output with test-logger plugin:
```kotlin
plugins {
id("cRelated in Cloud & DevOps
appbuilder-action-scaffolder
IncludedCreate, implement, deploy, and debug Adobe Runtime actions with consistent layout, validation, and error handling. Use this skill whenever the user needs to add actions to an App Builder project, understand action structure (params, response format, web/raw actions), configure actions in the manifest, use App Builder SDKs (State, Files, Events, database), deploy and invoke actions via CLI, debug action issues, or implement patterns such as webhook receivers, custom event providers, journaling consumers, large payload redirects, action sequence pipelines, and Asset Compute workers. Also trigger when users mention serverless functions in Adobe context, action logging, IMS authentication for actions, or cron-style scheduled actions.
orchestrating-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. Use this skill when the user needs a multi-step Data Cloud pipeline, cross-phase troubleshooting, or data space and data kit management. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase sf data360 workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching phase-specific skill), the task is STDM/session tracing/parquet telemetry (use observing-agentforce), standard CRM SOQL (use querying-soql), or Apex implementation (use generating-apex).
github-project-automation
IncludedAutomate GitHub repository setup with CI/CD workflows, issue templates, Dependabot, and CodeQL security scanning. Includes 12 production-tested workflows and prevents 18 errors: YAML syntax, action pinning, and configuration. Use when: setting up GitHub Actions CI/CD, creating issue/PR templates, enabling Dependabot or CodeQL scanning, deploying to Cloudflare Workers, implementing matrix testing, or troubleshooting YAML indentation, action version pinning, secrets syntax, runner versions, or CodeQL configuration. Keywords: github actions, github workflow, ci/cd, issue templates, pull request templates, dependabot, codeql, security scanning, yaml syntax, github automation, repository setup, workflow templates, github actions matrix, secrets management, branch protection, codeowners, github projects, continuous integration, continuous deployment, workflow syntax error, action version pinning, runner version, github context, yaml indentation error
sf-datacloud
IncludedSalesforce Data Cloud product orchestrator for connect→prepare→harmonize→segment→act workflows. TRIGGER when: user needs a multi-step Data Cloud pipeline, asks to set up or troubleshoot Data Cloud across phases, manages data spaces or data kits, or wants a cross-phase `sf data360` workflow. DO NOT TRIGGER when: work is isolated to a single phase (use the matching sf-datacloud-* skill), the task is STDM/session tracing/parquet telemetry (use sf-ai-agentforce-observability), standard CRM SOQL (use sf-soql), or Apex implementation (use sf-apex).
fabric-cli
IncludedUse this skill for Fabric.so CLI workflows with the `fabric` terminal command: diagnose/install/login, search or browse a Fabric library, save notes/links/files, create folders, ask the Fabric AI assistant, manage tasks/workspaces, generate shell completion, check subscription usage, produce JSON output, and use Fabric as persistent agent memory. Do not use for Microsoft Fabric/Azure/Power BI `fab`, Daniel Miessler's Fabric framework, Python Fabric SSH, Fabric.js, or textile/fashion fabric.
lark
IncludedLark/Feishu CLI skills: lark-cli operations for docs, markdown, sheets, base, calendar, im, mail, task, okr, drive, wiki, slides, whiteboard, apps, approval, attendance, contact, vc, minutes, event. Use when the user needs to operate Lark/Feishu resources via lark-cli, send messages, manage documents, spreadsheets, calendars, tasks, OKRs, deploy web pages, or any Feishu/Lark workspace operations.