unit-test-boundary-conditions

Solid

Provides edge case, corner case, boundary condition, and limit testing patterns for Java unit tests. Validates minimum/maximum values, null cases, empty collections, numeric overflow/underflow, floating-point precision, and off-by-one scenarios using JUnit 5 and AssertJ. Use when writing .java test files to ensure code handles limits, corner cases, and special inputs correctly.

Testing & QA 261 stars 29 forks Updated 1 weeks ago MIT

Install

View on GitHub

Quality Score: 89/100

Stars 20%
81
Recency 20%
90
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Unit Testing Boundary Conditions and Edge Cases ## Overview Systematic patterns for testing boundary conditions, corner cases, and limit values in Java using JUnit 5. Covers numeric boundaries, string edge cases, collection states, floating-point precision, date/time limits, and off-by-one scenarios. ## When to Use - Numeric min/max limits, null/empty/whitespace inputs - Overflow/underflow validation, collection boundaries - Off-by-one errors, floating-point precision ## Instructions 1. **Identify boundaries**: List numeric limits (MIN_VALUE, MAX_VALUE, zero), string states (null, empty, whitespace), collection sizes (0, 1, many) 2. **Apply parameterized tests**: Use `@ParameterizedTest` with `@ValueSource` or `@CsvSource` for multiple boundary values 3. **Test both sides of boundaries**: Cover values just below, at, and just above each boundary 4. **Run tests after adding each boundary category** to catch issues early 5. **Verify floating-point precision**: Use `isCloseTo(expected, within(tolerance))` with AssertJ 6. **Test collection states**: Explicitly test empty (0), single (1), and many (>1) element scenarios 7. **Handle overflow/underflow**: Use `Math.addExact()` and `Math.subtractExact()` to detect arithmetic overflow 8. **Test date/time edges**: Verify leap years, month boundaries, timezone transitions 9. **Iterate based on failures**: When a boundary test fails, analyze the error to discover additional untested boundaries; add test cases for the newly discov...

Details

Author
giuseppe-trisciuoglio
Repository
giuseppe-trisciuoglio/developer-kit
Created
7 months ago
Last Updated
1 weeks ago
Language
Python
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category

AI & Automation Listed

edge-case-coverage

Identify and document boundary conditions, corner cases, error scenarios, and validation requirements that implementations must handle. Use when the user asks to find edge cases, identify corner cases, specify validation rules, enumerate error scenarios, harden a function against bad inputs, or think through what can go wrong at the boundaries of a system. NOT for writing the actual tests (use testing-framework or test-driven-development). NOT for structured risk registers around project-level risks (use risk-management). NOT for security vulnerability scanning (use code-review).

9 Updated yesterday
viktorbezdek
Testing & QA Solid

unit-test-utility-methods

Provides patterns for testing utility classes, static methods, and helper functions. Validates pure functions, null handling, edge cases, and boundary conditions. Generates AssertJ assertions and @ParameterizedTest for string utils, math utils, validators, and collection helpers. Use when testing utils, test helpers, helper functions, static methods, or verifying utility code correctness.

261 Updated 1 weeks ago
giuseppe-trisciuoglio
Testing & QA Solid

131-java-testing-unit-testing

Use when you need to review, improve, or write Java unit tests — including migrating from JUnit 4 to JUnit 5, adopting AssertJ for fluent assertions, structuring tests with Given-When-Then, ensuring test independence, applying parameterized tests, mocking dependencies with Mockito, verifying boundary conditions (RIGHT-BICEP, CORRECT, A-TRIP), leveraging JSpecify null-safety annotations, or eliminating testing anti-patterns such as reflection-based tests or shared mutable state. This should trigger for requests such as Review Java code for unit tests; Apply best practices for unit tests in Java code. Part of cursor-rules-java project

393 Updated today
jabrena
Testing & QA Solid

unit-test-bean-validation

Provides patterns for unit testing Jakarta Bean Validation (JSR-380), including @Valid, @NotNull, @Min, @Max, @Email constraints with Hibernate Validator. Generates custom validator tests, constraint violation assertions, validation groups, and parameterized validation tests. Validates data integrity logic without Spring context. Use when writing validation tests, bean validation tests, or testing custom constraint validators.

261 Updated 1 weeks ago
giuseppe-trisciuoglio
Testing & QA Solid

130-java-testing-strategies

Use when you need to apply testing strategies for Java code — RIGHT-BICEP to guide test creation, A-TRIP for test quality characteristics, or CORRECT for verifying boundary conditions. This should trigger for requests such as Review Java code for testing strategies; Apply RIGHT-BICEP testing strategies in Java code; Apply A-TRIP testing strategies in Java code; Apply CORRECT boundary condition verification in Java code. Part of cursor-rules-java project

393 Updated today
jabrena