Agent skill

Unit Test Scheduled Async

by giuseppe-trisciuoglio in giuseppe-trisciuoglio/developer-kit

Provides patterns for unit testing Spring @Scheduled and @Async methods using JUnit 5, CompletableFuture, Awaitility, and Mockito.

MITAuto-check: notesTesting & QA

Install Unit Test Scheduled Async

skills CLI
$ npx skills add giuseppe-trisciuoglio/developer-kit --skill unit-test-scheduled-async -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install giuseppe-trisciuoglio/developer-kit unit-test-scheduled-async --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/giuseppe-trisciuoglio/developer-kit.git skills-src && mkdir -p .claude/skills && cp -r skills-src/plugins/developer-kit-java/skills/unit-test-scheduled-async .claude/skills/unit-test-scheduled-async && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
unit-test-scheduled-async
GitHub stars
357
Token cost
~1.5k tokens
SKILL.md length
391 words
Files
2 (incl. references)
Skills in repo
115
Repo updated
First seen
Licence
MIT

At a glance

Provides patterns for unit testing Spring @Scheduled and @Async methods using JUnit 5, CompletableFuture, Awaitility, and Mockito.

  • Works in 5 steps: Call @Async methods directly — bypass… → Mock dependencies with @Mock and… → Wait for completion — use… → …
  • Testing background tasks
  • SKILL.md covers Overview, When to Use, Instructions and Examples, plus 4 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Unit Test Scheduled Async is an agent skill from giuseppe-trisciuoglio/developer-kit. Provides patterns for unit testing Spring @Scheduled and @Async methods using JUnit 5, CompletableFuture, Awaitility, and Mockito. Covers mocking task execution and timing, verifying execution counts, testing cron expressions, validating retry behavior, and simulating thread pool behavior. Use when testing background tasks, cron jobs, periodic execution, scheduled tasks, or thread pool behavior.

Its SKILL.md is about 1.5k tokens, which your agent loads only when the skill is triggered. The skill folder holds 2 other files, including reference files (for example `references/examples.md`).

It sits in Testing & QA, covering Unit testing and Scheduled and recurring tasks. It works with JUnit. The repository describes itself as: Modular plugin marketplace for Claude Code and agentic CLIs, with validated, spec-driven skills, agents, commands, and workflows for Java, TypeScript, Python, PHP, AWS, and AI. The licence is MIT.

When your agent uses it

  • Testing background tasks
  • Periodic execution
  • Scheduled tasks
  • Thread pool behavior

Example prompts

  • “Use the unit-test-scheduled-async skill to provide patterns for unit testing Spring @Scheduled and @Async methods using JUnit 5, CompletableFuture…”
  • “/unit-test-scheduled-async”

Requirements

  • Pre-approved tools (allowed-tools): Read, Write, Bash, Glob, Grep

Workflow steps

5 steps, taken from the first numbered list in SKILL.md.

  1. Call @Async methods directly — bypass Spring's async proxy; the annotation is irrelevant in unit tests
  2. Mock dependencies with @Mock and @InjectMocks (Mockito)
  3. Wait for completion — use CompletableFuture.get(timeout, unit) or await().atMost(...).untilAsserted(...)
  4. Call @Scheduled methods directly — do not wait for cron/fixedRate; the annotation is ignored in unit tests
  5. Test exception paths — verify ExecutionException wrapping on CompletableFuture.get()

What it can do on your machine

Read from SKILL.md and the folder at commit fe73fb3. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Write
    • Bash
    • Glob
    • Grep

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md (its code samples are java).

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • docs.spring.io
    • github.com
    • docs.oracle.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Unit Test Scheduled Async loads about 1.5k tokens when it runs, and up to ~3.1k if it reads all its reference files. Until then it costs about 107 tokens; SKILL.md has 391 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~107
When it runs · the whole SKILL.md, loaded when a task matches
~1.5k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~3.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NotePre-approves every shell command (allowed-tools: Bash)SKILL.md
    allowed-tools: Read, Write, Bash, Glob, Grep

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from giuseppe-trisciuoglio/developer-kit at commit fe73fb3, republished under its MIT licence (© giuseppe-trisciuoglio). 391 words, ~1,458 tokens.

Download SKILL.mdSave it as .claude/skills/unit-test-scheduled-async/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
unit-test-scheduled-async
description
Provides patterns for unit testing Spring `@Scheduled` and `@Async` methods using JUnit 5, CompletableFuture, Awaitility, and Mockito. Covers mocking task execution and timing, verifying execution counts, testing cron expressions, validating retry behavior, and simulating thread pool behavior. Use when testing background tasks, cron jobs, periodic execution, scheduled tasks, or thread pool behavior.
allowed-tools
Read, Write, Bash, Glob, Grep

Unit Testing @Scheduled and @Async Methods

Overview

Patterns for unit testing Spring @Scheduled and @Async methods with JUnit 5. Test CompletableFuture results, use Awaitility for race conditions, mock scheduled task execution, and validate error handling — without waiting for real scheduling intervals.

When to Use

  • Testing @Scheduled method logic
  • Testing @Async method behavior
  • Verifying CompletableFuture results
  • Testing async error handling
  • Testing cron expression logic without waiting for actual scheduling
  • Validating thread pool behavior and execution counts
  • Testing background task logic in isolation

Instructions

  1. Call @Async methods directly — bypass Spring's async proxy; the annotation is irrelevant in unit tests
  2. Mock dependencies with @Mock and @InjectMocks (Mockito)
  3. Wait for completion — use CompletableFuture.get(timeout, unit) or await().atMost(...).untilAsserted(...)
  4. Call @Scheduled methods directly — do not wait for cron/fixedRate; the annotation is ignored in unit tests
  5. Test exception paths — verify ExecutionException wrapping on CompletableFuture.get()

Validation checkpoints:

  • After CompletableFuture.get(), assert the returned value before verifying mock interactions
  • If ExecutionException is thrown, check .getCause() to identify the root exception
  • If Awaitility times out, increase atMost() duration or reduce pollInterval() until the condition is reachable
  • After multiple task invocations, assert execution counts before verify() calls

Examples

Key patterns — complete examples in references/examples.md:

java
// @Async: call directly, wait with CompletableFuture.get(timeout, unit)
@Service
class EmailService {
  @Async
  public CompletableFuture<Boolean> sendEmailAsync(String to) {
    return CompletableFuture.supplyAsync(() -> true);
  }
}
@Test
void shouldReturnCompletedFuture() throws Exception {
  EmailService service = new EmailService();
  Boolean result = service.sendEmailAsync("test@example.com").get(5, TimeUnit.SECONDS);
  assertThat(result).isTrue();
}

// @Scheduled: call directly, mock the repository
@Component
class DataRefreshTask {
  @InjectMocks private DataRepository dataRepository;
  @Scheduled(fixedDelay = 60000) public void refreshCache() { /* ... */ }
}
@Test
void shouldRefreshCache() {
  when(dataRepository.findAll()).thenReturn(List.of(new Data(1L, "item1")));
  dataRefreshTask.refreshCache();
  verify(dataRepository).findAll();
}

// Awaitility: use for race conditions with shared mutable state
@Test
void shouldProcessAllItems() {
  BackgroundWorker worker = new BackgroundWorker();
  worker.processItems(List.of("item1", "item2", "item3"));
  Awaitility.await()
    .atMost(Duration.ofSeconds(5))
    .pollInterval(Duration.ofMillis(100))
    .untilAsserted(() -> assertThat(worker.getProcessedCount()).isEqualTo(3));
}

// Mocked dependencies with exception handling
@Test
void shouldHandleAsyncExceptionGracefully() {
  doThrow(new RuntimeException("Email failed")).when(emailService).send(any());
  CompletableFuture<String> result = service.notifyUserAsync("user123");
  assertThatThrownBy(result::get)
    .isInstanceOf(ExecutionException.class)
    .hasCauseInstanceOf(RuntimeException.class);
}

Full Maven/Gradle dependencies, additional test classes, and execution count patterns: see references/examples.md.

Show full SKILL.md (183 more words)Show less

Best Practices

  • Always set a timeout on CompletableFuture.get() to prevent hanging tests
  • Mock all dependencies — never call real external services in unit tests
  • Use Awaitility only for race conditions; prefer direct calls for simple async methods
  • Test @Scheduled logic directly — the annotation is ignored in unit tests
  • Assert values before verifying mock interactions; verify after async completion

Common Pitfalls

  • Relying on Spring's async executor instead of calling methods directly
  • Missing timeout on CompletableFuture.get()
  • Forgetting to test exception propagation in async methods
  • Not mocking dependencies that async methods invoke internally
  • Waiting for actual cron/fixedRate timing instead of testing logic in isolation

Constraints and Warnings

  • @Async self-invocation: calling @Async from another method in the same class executes synchronously — the Spring proxy is bypassed
  • Thread pool ordering: ThreadPoolTaskScheduler does not guarantee execution order
  • CompletableFuture chaining: exceptions in intermediate stages can be silently lost — test each stage
  • Awaitility timeout: always set a reasonable atMost(); infinite waits hang the test suite
  • No actual scheduling: @Scheduled is ignored in unit tests — call methods directly

References

© giuseppe-trisciuoglio, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file (references) in plugins/developer-kit-java/skills/unit-test-scheduled-async of giuseppe-trisciuoglio/developer-kit.

  • SKILL.md
  • references/examples.md

Open the folder on GitHubat commit fe73fb3

Compare with similar skills

Unit Test Scheduled Async next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Unit Test Scheduled Async compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Unit Test Scheduled Async this skillgiuseppe-trisciuoglio/developer-kit357—~1.5kAutomated safety check: NotesMIT
Running Instrumented Tests With Androidjunit4skydoves/android-testing-skills334—~4.5kAutomated safety check: PassApache-2.0
Debug Playwright Prowquay/quay2.8k—~2.2kAutomated safety check: PassApache-2.0
Quay Prow Triagequay/quay2.8k—~2.9kAutomated safety check: PassApache-2.0
Shopware CLIshopware/shopware-cli124—~4.9kAutomated safety check: PassMIT
Blue Teamgaasher/Agent-Loop-Skills174—~3.6kAutomated safety check: PassMIT

Similar skills

  • Running Instrumented Tests With Androidjunit4

    skydoves/android-testing-skills

    A skill your agent uses to stand up an Android instrumentation test source set with the canonical AndroidJUnit4 runner, the correct AndroidJUnitRunner Gradle wiring, and supporting infrastructure…

    334 GitHub stars~4.5k tokensUpdated 4 mo ago
    Testing & QAAuto-check passed
  • Deep-dive diagnosis of a Playwright test failure already isolated to one Quay Prow/OpenShift CI run: downloads its GCS artifacts (results.json, JUnit, build/pod logs, Jaeger traces), classifies real…

    2.8k GitHub stars~2.2k tokensUpdated yesterday
    Testing & QAAuto-check passed
  • Diagnose any Quay Prow job failure end to end: prowjob.json - top-level build log - JUnit - resolved failing step - Playwright results.json when the failing step is Playwright, continuing through…

    2.8k GitHub stars~2.9k tokensUpdated yesterday
    Testing & QAAuto-check passed
  • Shopware CLI

    shopware/shopware-cli

    Use Shopware CLI for Shopware project, extension, and account workflows — create and install new projects (project create, project dev install), validate projects or extensions (with…

    124 GitHub stars~4.9k tokensUpdated 4 days ago
    Testing & QAAuto-check passed
  • Blue Team

    gaasher/Agent-Loop-Skills

    A skill your agent uses when the user has concrete failing cases in code or a guardrail/classifier/filter/prompt/API they own — a red-team failure catalogue OR a CI/CD test-failure report (failing…

    174 GitHub stars~3.6k tokensUpdated 3 mo ago
    Testing & QAAuto-check passed
  • Debug Surefire

    eclipse-rdf4j/rdf4j

    Debug Maven Surefire unit tests by running them in JDWP "wait for debugger" mode (-Dmaven.surefire.debug) and attaching to the forked test JVM using jdb (preferred for CLI/agent debugging)…

    420 GitHub stars~2.4k tokensUpdated 2 days ago
    Testing & QAAuto-check passed

More from giuseppe-trisciuoglio/developer-kit

All 115 skills in this repo
  • Nestjs Drizzle Crud Generator

    giuseppe-trisciuoglio/developer-kit

    Generates complete CRUD modules for NestJS applications with Drizzle ORM.

    357 GitHub stars~1.3k tokensUpdated 1 mo ago
    Auto-check: notes
  • Spring Boot Actuator

    giuseppe-trisciuoglio/developer-kit

    Provides patterns to configure Spring Boot Actuator for production-grade monitoring, health probes, secured management endpoints, and Micrometer metrics across JVM services.

    357 GitHub stars~2.2k tokensUpdated 1 mo ago
    Auto-check: notes
  • Spring Boot Crud Patterns

    giuseppe-trisciuoglio/developer-kit

    Provides and generates complete CRUD workflows for Spring Boot 3 services.

    357 GitHub stars~2.5k tokensUpdated 1 mo ago
    Auto-check: notes
  • Spring Boot Security JWT

    giuseppe-trisciuoglio/developer-kit

    Provides JWT authentication and authorization patterns for Spring Boot 3.5.x covering token generation with JJWT, Bearer/cookie authentication, database/OAuth2 integration, and RBAC/permission-based…

    357 GitHub stars~3.9k tokensUpdated 1 mo ago
    Auto-check: notes
  • AWS CLI Beast

    giuseppe-trisciuoglio/developer-kit

    Provides advanced AWS CLI patterns for managing EC2, Lambda, S3, DynamoDB, RDS, VPC, IAM, and CloudWatch.

    357 GitHub stars~1.7k tokensUpdated 1 mo ago
    Auto-check: notes
  • PR Review Comments

    giuseppe-trisciuoglio/developer-kit

    Posts review findings from a JSON file as inline comments on a GitHub Pull Request, attaching each comment to its file and line.

    357 GitHub stars~1k tokensUpdated 1 mo ago
    Auto-check: notes

Works with

Questions about Unit Test Scheduled Async

What does Unit Test Scheduled Async do?

Provides patterns for unit testing Spring @Scheduled and @Async methods using JUnit 5, CompletableFuture, Awaitility, and Mockito. Unit Test Scheduled Async is an agent skill from giuseppe-trisciuoglio/developer-kit. Provides patterns for unit testing Spring @Scheduled and @Async methods using JUnit 5, CompletableFuture, Awaitility, and Mockito.

When should I use Unit Test Scheduled Async?

Unit Test Scheduled Async fits situations like: testing background tasks; periodic execution; scheduled tasks; thread pool behavior.

How do I install Unit Test Scheduled Async in Claude Code?

Run `npx skills add giuseppe-trisciuoglio/developer-kit --skill unit-test-scheduled-async -a claude-code`. Or copy the skill folder (plugins/developer-kit-java/skills/unit-test-scheduled-async in giuseppe-trisciuoglio/developer-kit) into .claude/skills/unit-test-scheduled-async in your project. Claude Code loads it when a task matches its description.

How do I install Unit Test Scheduled Async in Codex?

Run `npx skills add giuseppe-trisciuoglio/developer-kit --skill unit-test-scheduled-async -a codex`. Or copy the skill folder (plugins/developer-kit-java/skills/unit-test-scheduled-async in giuseppe-trisciuoglio/developer-kit) into .agents/skills/unit-test-scheduled-async in your project. Codex loads it when a task matches its description.

Can I use Unit Test Scheduled Async in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add giuseppe-trisciuoglio/developer-kit --skill unit-test-scheduled-async -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/unit-test-scheduled-async, .gemini/skills/unit-test-scheduled-async, .github/skills/unit-test-scheduled-async and .opencode/skills/unit-test-scheduled-async in your project.

What does Unit Test Scheduled Async need to run?

SKILL.md names no scripts, command-line tools or credentials: Unit Test Scheduled Async is instructions for the agent only. Its frontmatter pre-approves these tools: Read, Write, Bash, Glob, Grep.

Does Unit Test Scheduled Async access the network?

SKILL.md names 3 domains. As links in the text: docs.spring.io, github.com and docs.oracle.com. This is read from the text; nothing was executed.

Is Unit Test Scheduled Async safe to install?

Our automated static check of SKILL.md found notes only (pre-approves every shell command (allowed-tools: bash)), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Unit Test Scheduled Async use?

Unit Test Scheduled Async is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Unit Test Scheduled Async use?

About 1.5k tokens (SKILL.md is roughly 5.8k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 1.6k tokens, read only when the agent opens those files.

What are the alternatives to Unit Test Scheduled Async?

Skills that share tags, products or a category with Unit Test Scheduled Async: Running Instrumented Tests With Androidjunit4 (skydoves/android-testing-skills, 334 stars), Debug Playwright Prow (quay/quay, 2.8k stars), Quay Prow Triage (quay/quay, 2.8k stars) and Shopware CLI (shopware/shopware-cli, 124 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Unit Test Scheduled Async?

giuseppe-trisciuoglio (a GitHub user) maintains it in giuseppe-trisciuoglio/developer-kit, which has 357 GitHub stars. The repository holds 115 skills in this directory. The repository was last updated on September 10, 2026.

Source: giuseppe-trisciuoglio/developer-kit on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.