{"kind":"Skill","metadata":{"namespace":"community","name":"java-junit","version":"0.1.0"},"spec":{"description":"Get best practices for JUnit 5 unit testing, including data-driven tests","files":{"SKILL.md":"---\nname: java-junit\ndescription: 'Get best practices for JUnit 5 unit testing, including data-driven tests'\n---\n\n# 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.\n"},"import":{"commit_sha":"541b7819d8c3545c6df122491af4fa1eae415779","imported_at":"2026-05-18T20:05:35Z","license_text":"MIT License\n\nCopyright GitHub, Inc.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.","owner":"github","repo":"github/awesome-copilot","source_url":"https://github.com/github/awesome-copilot/tree/541b7819d8c3545c6df122491af4fa1eae415779/plugins/java-development/skills/java-junit"}},"content_hash":[73,127,44,114,96,74,234,214,35,23,116,36,56,233,89,153,220,134,214,109,218,36,81,149,29,52,144,152,113,110,45,227],"trust_level":"unsigned","yanked":false}
