{"id":"b99507d1-46cd-4edd-9c01-618786450943","shortId":"MaAZB6","kind":"skill","title":"java-junit","tagline":"Get best practices for JUnit 5 unit testing, including data-driven tests","description":"# JUnit 5+ Best Practices\n\nYour goal is to help me write effective unit tests with JUnit 5, covering both standard and data-driven testing approaches.\n\n## Project Setup\n\n- Use a standard Maven or Gradle project structure.\n- Place test source code in `src/test/java`.\n- Include dependencies for `junit-jupiter-api`, `junit-jupiter-engine`, and `junit-jupiter-params` for parameterized tests.\n- Use build tool commands to run tests: `mvn test` or `gradle test`.\n\n## Test Structure\n\n- Test classes should have a `Test` suffix, e.g., `CalculatorTest` for a `Calculator` class.\n- Use `@Test` for test methods.\n- Follow the Arrange-Act-Assert (AAA) pattern.\n- Name tests using a descriptive convention, like `methodName_should_expectedBehavior_when_scenario`.\n- Use `@BeforeEach` and `@AfterEach` for per-test setup and teardown.\n- Use `@BeforeAll` and `@AfterAll` for per-class setup and teardown (must be static methods).\n- Use `@DisplayName` to provide a human-readable name for test classes and methods.\n\n## Standard Tests\n\n- Keep tests focused on a single behavior.\n- Avoid testing multiple conditions in one test method.\n- Make tests independent and idempotent (can run in any order).\n- Avoid test interdependencies.\n\n## Data-Driven (Parameterized) Tests\n\n- Use `@ParameterizedTest` to mark a method as a parameterized test.\n- Use `@ValueSource` for simple literal values (strings, ints, etc.).\n- Use `@MethodSource` to refer to a factory method that provides test arguments as a `Stream`, `Collection`, etc.\n- Use `@CsvSource` for inline comma-separated values.\n- Use `@CsvFileSource` to use a CSV file from the classpath.\n- Use `@EnumSource` to use enum constants.\n\n## Assertions\n\n- Use the static methods from `org.junit.jupiter.api.Assertions` (e.g., `assertEquals`, `assertTrue`, `assertNotNull`).\n- For more fluent and readable assertions, consider using a library like AssertJ (`assertThat(...).is...`).\n- Use `assertThrows` or `assertDoesNotThrow` to test for exceptions.\n- Group related assertions with `assertAll` to ensure all assertions are checked before the test fails.\n- Use descriptive messages in assertions to provide clarity on failure.\n\n## Mocking and Isolation\n\n- Use a mocking framework like Mockito to create mock objects for dependencies.\n- Use `@Mock` and `@InjectMocks` annotations from Mockito to simplify mock creation and injection.\n- Use interfaces to facilitate mocking.\n\n## Test Organization\n\n- Group tests by feature or component using packages.\n- Use `@Tag` to categorize tests (e.g., `@Tag(\"fast\")`, `@Tag(\"integration\")`).\n- Use `@TestMethodOrder(MethodOrderer.OrderAnnotation.class)` and `@Order` to control test execution order when strictly necessary.\n- Use `@Disabled` to temporarily skip a test method or class, providing a reason.\n- Use `@Nested` to group tests in a nested inner class for better organization and structure.","tags":["java","junit","awesome","copilot","github","agent-skills","agents","custom-agents","github-copilot","hacktoberfest","prompt-engineering"],"capabilities":["skill","source-github","skill-java-junit","topic-agent-skills","topic-agents","topic-awesome","topic-custom-agents","topic-github-copilot","topic-hacktoberfest","topic-prompt-engineering"],"categories":["awesome-copilot"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/github/awesome-copilot/java-junit","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add github/awesome-copilot","source_repo":"https://github.com/github/awesome-copilot","install_from":"skills.sh"}},"qualityScore":"0.700","qualityRationale":"deterministic score 0.70 from registry signals: · indexed on github topic:agent-skills · 33270 github stars · SKILL.md body (2,866 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-05-18T18:52:15.084Z","embedding":null,"createdAt":"2026-04-18T20:25:30.547Z","updatedAt":"2026-05-18T18:52:15.084Z","lastSeenAt":"2026-05-18T18:52:15.084Z","tsv":"'5':9,18,33 'aaa':116 'act':114 'afteral':144 'aftereach':133 'annot':342 'api':65 'approach':42 'argument':235 'arrang':113 'arrange-act-assert':112 'assert':115,265,281,300,306,317 'assertal':302 'assertdoesnotthrow':293 'assertequ':273 'assertj':287 'assertnotnul':275 'assertthat':288 'assertthrow':291 'asserttru':274 'avoid':179,197 'beforeal':142 'beforeeach':131 'behavior':178 'best':5,19 'better':413 'build':79 'calcul':103 'calculatortest':100 'categor':369 'check':308 'clariti':320 'class':93,104,148,167,398,411 'classpath':258 'code':56 'collect':239 'comma':246 'comma-separ':245 'command':81 'compon':363 'condit':182 'consid':282 'constant':264 'control':382 'convent':123 'cover':34 'creat':333 'creation':348 'csv':254 'csvfilesourc':250 'csvsourc':242 'data':14,39,201 'data-driven':13,38,200 'depend':60,337 'descript':122,314 'disabl':390 'displaynam':157 'driven':15,40,202 'e.g':99,272,371 'effect':28 'engin':69 'ensur':304 'enum':263 'enumsourc':260 'etc':223,240 'except':297 'execut':384 'expectedbehavior':127 'facilit':354 'factori':230 'fail':312 'failur':322 'fast':373 'featur':361 'file':255 'fluent':278 'focus':174 'follow':110 'framework':329 'get':4 'goal':22 'gradl':50,88 'group':298,358,405 'help':25 'human':162 'human-read':161 'idempot':191 'includ':12,59 'independ':189 'inject':350 'injectmock':341 'inlin':244 'inner':410 'int':222 'integr':375 'interdepend':199 'interfac':352 'isol':325 'java':2 'java-junit':1 'junit':3,8,17,32,63,67,72 'junit-jupiter-api':62 'junit-jupiter-engin':66 'junit-jupiter-param':71 'jupit':64,68,73 'keep':172 'librari':285 'like':124,286,330 'liter':219 'make':187 'mark':208 'maven':48 'messag':315 'method':109,155,169,186,210,231,269,396 'methodnam':125 'methodorderer.orderannotation.class':378 'methodsourc':225 'mock':323,328,334,339,347,355 'mockito':331,344 'multipl':181 'must':152 'mvn':85 'name':118,164 'necessari':388 'nest':403,409 'object':335 'one':184 'order':196,380,385 'org.junit.jupiter.api.assertions':271 'organ':357,414 'packag':365 'param':74 'parameter':76,203,213 'parameterizedtest':206 'pattern':117 'per':136,147 'per-class':146 'per-test':135 'place':53 'practic':6,20 'project':43,51 'provid':159,233,319,399 'readabl':163,280 'reason':401 'refer':227 'relat':299 'run':83,193 'scenario':129 'separ':247 'setup':44,138,149 'simpl':218 'simplifi':346 'singl':177 'skill' 'skill-java-junit' 'skip':393 'sourc':55 'source-github' 'src/test/java':58 'standard':36,47,170 'static':154,268 'stream':238 'strict':387 'string':221 'structur':52,91,416 'suffix':98 'tag':367,372,374 'teardown':140,151 'temporarili':392 'test':11,16,30,41,54,77,84,86,89,90,92,97,106,108,119,137,166,171,173,180,185,188,198,204,214,234,295,311,356,359,370,383,395,406 'testmethodord':377 'tool':80 'topic-agent-skills' 'topic-agents' 'topic-awesome' 'topic-custom-agents' 'topic-github-copilot' 'topic-hacktoberfest' 'topic-prompt-engineering' 'unit':10,29 'use':45,78,105,120,130,141,156,205,215,224,241,249,252,259,262,266,283,290,313,326,338,351,364,366,376,389,402 'valu':220,248 'valuesourc':216 'write':27","prices":[{"id":"d414474e-5f85-4392-a31a-b73e96425c34","listingId":"b99507d1-46cd-4edd-9c01-618786450943","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"github","category":"awesome-copilot","install_from":"skills.sh"},"createdAt":"2026-04-18T20:25:30.547Z"}],"sources":[{"listingId":"b99507d1-46cd-4edd-9c01-618786450943","source":"github","sourceId":"github/awesome-copilot/java-junit","sourceUrl":"https://github.com/github/awesome-copilot/tree/main/skills/java-junit","isPrimary":false,"firstSeenAt":"2026-04-18T21:49:55.722Z","lastSeenAt":"2026-05-18T18:52:15.084Z"},{"listingId":"b99507d1-46cd-4edd-9c01-618786450943","source":"skills_sh","sourceId":"github/awesome-copilot/java-junit","sourceUrl":"https://skills.sh/github/awesome-copilot/java-junit","isPrimary":true,"firstSeenAt":"2026-04-18T20:25:30.547Z","lastSeenAt":"2026-05-07T22:40:17.214Z"}],"details":{"listingId":"b99507d1-46cd-4edd-9c01-618786450943","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"github","slug":"java-junit","github":{"repo":"github/awesome-copilot","stars":33270,"topics":["agent-skills","agents","ai","awesome","custom-agents","github-copilot","hacktoberfest","prompt-engineering"],"license":"mit","html_url":"https://github.com/github/awesome-copilot","pushed_at":"2026-05-18T01:26:59Z","description":"Community-contributed instructions, agents, skills, and configurations to help you make the most of GitHub Copilot.","skill_md_sha":"b5da58d17eb7fa509baaca6974d77b91c94c7735","skill_md_path":"skills/java-junit/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/github/awesome-copilot/tree/main/skills/java-junit"},"layout":"multi","source":"github","category":"awesome-copilot","frontmatter":{"name":"java-junit","description":"Get best practices for JUnit 5 unit testing, including data-driven tests"},"skills_sh_url":"https://skills.sh/github/awesome-copilot/java-junit"},"updatedAt":"2026-05-18T18:52:15.084Z"}}