java-unit-test

java-unit-test is a skill for Codex from hashgraph-online/awesome-codex-plugins. It costs 113 tokens per session (1,865 once invoked), scanned A, original, Apache-2.0.

A code-generation guide for Java unit tests in Spring Boot projects. Unit tests check one small piece of code in isolation; Spring Boot is a Java framework for building web applications and services.

In plain words
What is it for?
Use it to create JUnit 5 tests with Mockito, AssertJ, or MockMvc for Spring Boot services, controllers, and mappers, including success and failure cases.
Why use it?
It gives tests a consistent structure and selects suitable approaches for services, controllers, and data-access code. It also avoids starting the full application when a smaller test is enough.

Skill for Codex

Written for Codex: agents/openai.yaml present.

Good fit Use it to create JUnit 5 tests with Mockito, AssertJ, or MockMvc for Spring Boot services, controllers, and mappers, including success and failure cases.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/hashgraph-online/awesome-codex-plugins/java-unit-test
About the project

Awesome Codex Plugins is a curated catalogue and marketplace of installable plugins, skills, and related resources for OpenAI Codex and ChatGPT. It helps people find, create, validate, and submit extensions for Codex workflows across its app, command-line interface, and IDE extensions. The catalogue add-ons are the plugins, skills, agents, and hooks listed or supported by this project.

hashgraph-online/awesome-codex-plugins · 1,647 stars · on GitHub · hol.org

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add hashgraph-online/awesome-codex-plugins --skill java-unit-test
Clone the repo
git clone --depth 1 https://github.com/hashgraph-online/awesome-codex-plugins

Made for: Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for java-unit-test

README.md
[![agentmods](https://agentmods.dev/badge/skills/hashgraph-online/awesome-codex-plugins/java-unit-test/github.svg)](https://agentmods.dev/skills/hashgraph-online/awesome-codex-plugins/java-unit-test)
Your own site
<a href="https://agentmods.dev/skills/hashgraph-online/awesome-codex-plugins/java-unit-test"><img src="https://agentmods.dev/badge/skills/hashgraph-online/awesome-codex-plugins/java-unit-test/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for java-unit-test

Your own site · 80×15
<a href="https://agentmods.dev/skills/hashgraph-online/awesome-codex-plugins/java-unit-test"><img src="https://agentmods.dev/badge/skills/hashgraph-online/awesome-codex-plugins/java-unit-test.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 113 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,865 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00113 $0.01865
Opus 5.5 $0.00045 $0.00746
Sonnet 5.5 $0.00023 $0.00373
Haiku 4.5 $0.00011 $0.00186

Measured 3mo ago against content hash 7e59f30ebb0b, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

java-unit-test scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/Colin4k1024/tsp/skills/java-unit-test/SKILL.md · 257 lines

How it starts

The opening of the file, as written. The whole thing — 257 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Java 单元测试代码生成专家

你是一个专业的 Java 单元测试代码生成专家,擅长使用 JUnit 5、Mockito、MockMvc 框架为 Spring Boot 项目编写高质量测试代码。

技术栈

框架 用途
JUnit 5 (Jupiter) 测试框架
Mockito Mock 与 Stub
AssertJ 断言(优先 assertThat)
MockMvc Web 层测试

遵循 AAA 模式(Arrange-Act-Assert)。

代码规范

  • 测试类放在 src/test/java,包路径与被测类一致
  • 测试类命名:被测类名 + Test
  • 测试方法命名:test + 方法名 + 场景描述(驼峰)
  • 每个测试方法只测试一个场景
  • 使用 @DisplayName 提供可读的中文描述

根据被测层选择测试模式

1. 业务逻辑层(ServiceImpl / Step 等)

依赖项全部 Mock,不启动 Spring 容器。

@ExtendWith(MockitoExtension.class)
@DisplayName("申请单服务 - 提交申请")
class ApplicationServiceImplTest {

    @Mock
    ApplicationMapper applicationMapper;

    @InjectMocks
    ApplicationServiceImpl applicationService;

    @Test
    @DisplayName("正常提交:保存成功返回申请单ID")
    void testSubmit_success() {
        // Arrange
        SubmitRequest req = new SubmitRequest("张三", "001");
        when(applicationMapper.insert(any())).thenReturn(1);

        // Act
        Long result = applicationService.submit(req);

        // Assert
        assertThat(result).isNotNull();
        verify(applicationMapper).insert(any());
    }

    @Test
    @DisplayName("提交失败:insert 返回0时抛出 BizErrorException")
    void testSubmit_insertFail_throwsBizError() {
        when(applicationMapper.insert(any())).thenReturn(0);

        assertThatThrownBy(() -> applicationService.submit(new SubmitRequest("张三", "001")))
            .isInstanceOf(BizErrorException.class);
    }
}

Mockito 约定:

  • 优先显式 stub(when(...).thenReturn(...)),避免 @Spy / 部分 Mock
  • 多场景变体用 @ParameterizedTest
  • @BeforeEach 中禁止放置非所有测试都需要的 stub:MockitoExtension 默认严格模式,未使用的 stub 会抛 UnnecessaryStubbingException
    • 推荐:stub 移到具体测试方法内,@BeforeEach 只做对象初始化
    • 次选:确实大多数测试需要、少数例外不用时,用 lenient().when(...).thenReturn(...)
// 推荐
@Test
void testSubmit_success() {
    when(userService.getCurrentUser()).thenReturn(mockUser);
    // ...
}

// 次选
@BeforeEach
void setup() {
    lenient().when(userService.getCurrentUser()).thenReturn(mockUser);
}

Read the full file on GitHub · 257 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3mo ago First seen · 257 lines · 113 tokens per session scan A 7e59f30ebb0b

Subscribe to this mod's changes

java-unit-test is a skill published in the GitHub repository hashgraph-online/awesome-codex-plugins (1,647 stars, last pushed yesterday), licensed Apache-2.0. It adds 113 tokens to every session and 1,865 once invoked, about $0.0005 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-05.

Related

java-unit-test compared with skills from other repositories

java-unit-test next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
java-unit-testhashgraph-online/awesome-codex-pluginsSkill1.6kyesterdayApache-2.0A113Codex
junit-mockitoalmasumdev/awesome-java-android-agent-skillsSkill17mo agononeA45Claude Code, Codex
ax-java-agent-rlmax-llm/axSkill3.0ktodayApache-2.0A44Claude Code, Codex
130-java-testing-strategiesjabrena/plinthSkill470yesterdayApache-2.0A96Claude Code, Codex
421-frameworks-quarkus-testing-unit-testsjabrena/plinthSkill470yesterdayApache-2.0A205Claude Code, Codex
perl-testingloulanyue/awesome-claude-notesSkill2712mo agoMITA35Claude Code
java-coding-standardsloulanyue/awesome-claude-notesSkill2712mo agoMITA50Claude Code