askill
junit-core

junit-coreSafety 100Repository

JUnit 5 core testing patterns with AAA structure, test organization, and coverage standards

2 stars
1.2k downloads
Updated 3/6/2026

Package Files

Loading files...
SKILL.md

JUnit Core Skill

REFERENCE MODE: This skill provides reference material. Load specific standards on-demand based on current task.

JUnit 5 testing standards for general Java projects. This skill covers test structure, naming conventions, coverage requirements, and the AAA (Arrange-Act-Assert) pattern.

Prerequisites

This skill applies to Java projects using JUnit 5:

  • org.junit.jupiter:junit-jupiter (JUnit 5)

Workflow

Step 1: Load Core Testing Standards

Important: Load this standard for any testing work.

Read: standards/testing-junit-core.md

This provides foundational rules for:

  • Test class requirements (1:1 mapping, splitting at 200+ lines)
  • AAA pattern with generated test data (no literals, no phase comments)
  • Full JUnit 5 assertion API (assertAll, assertInstanceOf, assertDoesNotThrow)
  • @Nested for grouping (3+ related tests)
  • Corner case testing
  • Coverage requirements (80% line/branch minimum)

Step 2: Load Additional Standards (As Needed)

Integration Testing (load for IT work):

Read: standards/testing-integration.md

Use when: Writing or reviewing integration tests (*IT.java). Covers naming, separation, and lifecycle.

Async Testing (load for async/concurrent code):

Read: standards/testing-async-patterns.md

Use when: Testing asynchronous behavior. Covers Awaitility patterns (never Thread.sleep).

Coverage Analysis (load for coverage work):

Read: standards/coverage-analysis-pattern.md

Use when: Analyzing test coverage or improving coverage metrics.

Key Rules Summary

Test Class Requirements

// CORRECT - One test class per production class
// TokenValidator.java → TokenValidatorTest.java
// UserService.java → UserServiceTest.java

AAA Pattern — No Phase Comments

@Test
@DisplayName("Should validate token with correct issuer")
void shouldValidateTokenWithCorrectIssuer() {
    var issuer = Generators.nonBlankStrings().next();
    var token = createTokenWithIssuer(issuer);

    var result = validator.validate(token);

    assertTrue(result.isValid(), "Token should be valid");
    assertEquals(issuer, result.getIssuer(), "Issuer should match");
}

Grouped Assertions with assertAll

@Test
@DisplayName("Should parse all token claims")
void shouldParseAllTokenClaims() {
    var token = createValidToken();

    var claims = parser.parse(token);

    assertAll("Token claims",
        () -> assertNotNull(claims.getSubject(), "Subject should be present"),
        () -> assertInstanceOf(Instant.class, claims.getExpiry(), "Expiry should be Instant"),
        () -> assertFalse(claims.getRoles().isEmpty(), "Roles should not be empty")
    );
}

Coverage Requirements

  • Minimum 80% line coverage
  • Minimum 80% branch coverage
  • Critical/hot paths: near 100% coverage
  • All public APIs must be tested

Related Skills

  • pm-dev-java:junit-integration - Maven integration testing
  • pm-dev-java-cui:cui-testing - CUI test generator framework
  • pm-dev-java:java-core - Core Java patterns

Standards Reference

StandardPurpose
testing-junit-core.mdTest structure, AAA pattern, assertions, nesting
testing-integration.mdIntegration test naming, separation, lifecycle
testing-async-patterns.mdAwaitility patterns (never Thread.sleep)
coverage-analysis-pattern.mdCoverage analysis and gap improvement

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

79/100Analyzed 3/8/2026

Well-structured JUnit 5 reference skill with clear AAA pattern examples, code samples, and organized workflow. Provides good technical depth but relies heavily on loading external standards files, making it less immediately actionable. The marketplace path suggests reusability, though internal skill references and repo mention indicate project-specific tailoring. Tags improve discoverability.

100
85
72
82
70

Metadata

Licenseunknown
Version-
Updated3/6/2026
Publishercuioss

Tags

apigithub-actionsobservabilitytesting