
Unit Test Boundary Conditions
Copy battle-tested JUnit patterns for nulls, concurrency, atomics, and parameterized edge cases in unit tests.
Install
npx skills add https://github.com/giuseppe-trisciuoglio/developer-kit --skill unit-test-boundary-conditionsWhat is this skill?
- ConcurrentHashMap null and absent-key boundary examples
- CopyOnWriteArrayList concurrent modification during iteration
- BlockingQueue empty poll and AtomicInteger overflow-style cases
- Synchronized block and atomic increment patterns for thread safety
- Parameterized boundary cases via JUnit Jupiter CsvSource
Adoption & trust: 1.5k installs on skills.sh; 271 GitHub stars; 3/3 security scanners passed (skills.sh audits).
Recommended Skills
Agent Browservercel-labs/open-agents
Tddmattpocock/skills
Use My Browserxixu-me/skills
Test Driven Developmentobra/superpowers
Verification Before Completionobra/superpowers
Webapp Testinganthropics/skills
Journey fit
Primary fit
Boundary and concurrency tests belong in Ship when you harden logic before release, not during initial ideation. testing is the canonical shelf because the skill is a reference of unit-test scenarios for edge and thread-safety boundaries.
Common Questions / FAQ
Is Unit Test Boundary Conditions safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Unit Test Boundary Conditions
# Concurrent Boundary Testing Reference ## Null and Race Conditions ```java import java.util.concurrent.*; class ConcurrentBoundaryTest { @Test void shouldHandleNullInConcurrentMap() { ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>(); map.put("key", "value"); assertThat(map.get("nonexistent")).isNull(); } @Test void shouldHandleConcurrentModification() { List<Integer> list = new CopyOnWriteArrayList<>(List.of(1, 2, 3, 4, 5)); for (int num : list) { if (num == 3) { list.add(6); } } assertThat(list).hasSize(6); } @Test void shouldHandleEmptyBlockingQueue() throws InterruptedException { BlockingQueue<String> queue = new LinkedBlockingQueue<>(); assertThat(queue.poll()).isNull(); } } ``` ## Thread Safety Patterns ```java class ThreadSafetyBoundaryTest { @Test void shouldHandleAtomicOperations() { AtomicInteger counter = new AtomicInteger(0); counter.incrementAndGet(); counter.addAndGet(Integer.MAX_VALUE); assertThat(counter.get()).isGreaterThan(0); } @Test void shouldHandleSynchronizedBlocks() { Object lock = new Object(); int[] count = {0}; synchronized (lock) { count[0]++; } assertThat(count[0]).isEqualTo(1); } } ``` # Parameterized Boundary Testing Reference ## Multiple Boundary Cases ```java import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; class ParameterizedBoundaryTest { @ParameterizedTest @CsvSource({ "null, false", "'', false", "' ', false", "a, true", "abc, true" }) void shouldValidateStringBoundaries(String input, boolean expected) { boolean result = StringValidator.isValid(input); assertThat(result).isEqualTo(expected); } @ParameterizedTest @ValueSource(ints = {Integer.MIN_VALUE, 0, 1, -1, Integer.MAX_VALUE}) void shouldHandleNumericBoundaries(int value) { assertThat(value).isNotNull(); } static Stream<Arguments> edgeCaseProvider() { return Stream.of( Arguments.of(Integer.MIN_VALUE, "min"), Arguments.of(-1, "negative"), Arguments.of(0, "zero"), Arguments.of(1, "positive"), Arguments.of(Integer.MAX_VALUE, "max") ); } @ParameterizedTest @MethodSource("edgeCaseProvider") void shouldTestAllEdgeCases(int value, String description) { assertThat(value).isNotNull(); } } ``` ## Off-By-One Testing ```java class OffByOneBoundaryTest { @ParameterizedTest @CsvSource({ "-1, false", "0, true", "1, true", "99, true", "100, false", "101, false" }) void shouldValidateRangeBoundaries(int value, boolean expected) { boolean inRange = value >= 0 && value <= 100; assertThat(inRange).isEqualTo(expected); } @Test void shouldHandleArrayIndexOffByOne() { int[] array = {1, 2, 3}; assertThat(array.length).isEqualTo(3); assertThat(array[0]).isEqualTo(1); assertThat(array[array.length - 1]).isEqualTo(3); } } ``` --- name: unit-test-boundary-conditions description: 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. allowed-tools: Read, Write, Bash, Glob, Grep --- # 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. #