java-junit by github/awesome-copilot
npx skills add https://github.com/github/awesome-copilot --skill java-junit你的目标是帮助我编写有效的 JUnit 5 单元测试,涵盖标准和数据驱动的测试方法。
src/test/java 目录下。junit-jupiter-api、junit-jupiter-engine 以及用于参数化测试的 junit-jupiter-params 的依赖项。mvn test 或 gradle test。Test 后缀,例如,Calculator 类的测试类命名为 。广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
CalculatorTest@Test 注解标记测试方法。methodName_should_expectedBehavior_when_scenario。@BeforeEach 和 @AfterEach 进行每个测试的初始化和清理工作。@BeforeAll 和 @AfterAll 进行每个测试类的初始化和清理工作(必须是静态方法)。@DisplayName 为测试类和方法提供人类可读的名称。@ParameterizedTest 将方法标记为参数化测试。@ValueSource 提供简单的字面值(字符串、整数等)。@MethodSource 引用一个工厂方法,该方法提供 Stream、Collection 等形式的测试参数。@CsvSource 提供内联的逗号分隔值。@CsvFileSource 从类路径加载 CSV 文件。@EnumSource 使用枚举常量。org.junit.jupiter.api.Assertions 中的静态方法(例如 assertEquals、assertTrue、assertNotNull)。assertThat(...).is...)。assertThrows 或 assertDoesNotThrow 来测试异常。assertAll 将相关的断言分组,以确保在测试失败前检查所有断言。@Mock 和 @InjectMocks 注解来简化模拟对象的创建和注入。@Tag 对测试进行分类(例如 @Tag("fast")、@Tag("integration"))。@TestMethodOrder(MethodOrderer.OrderAnnotation.class) 和 @Order 来控制测试的执行顺序。@Disabled 临时跳过某个测试方法或类,并提供原因。@Nested 在嵌套的内部类中对测试进行分组,以获得更好的组织和结构。每周安装量
7.8K
仓库
GitHub 星标数
26.9K
首次出现
2026年2月25日
安全审计
安装于
codex7.7K
gemini-cli7.7K
opencode7.7K
cursor7.7K
github-copilot7.7K
kimi-cli7.7K
Your goal is to help me write effective unit tests with JUnit 5, covering both standard and data-driven testing approaches.
src/test/java.junit-jupiter-api, junit-jupiter-engine, and junit-jupiter-params for parameterized tests.mvn test or gradle test.Test suffix, e.g., CalculatorTest for a Calculator class.@Test for test methods.methodName_should_expectedBehavior_when_scenario.@BeforeEach and @AfterEach for per-test setup and teardown.@BeforeAll and @AfterAll for per-class setup and teardown (must be static methods).@DisplayName to provide a human-readable name for test classes and methods.@ParameterizedTest to mark a method as a parameterized test.@ValueSource for simple literal values (strings, ints, etc.).@MethodSource to refer to a factory method that provides test arguments as a Stream, Collection, etc.@CsvSource for inline comma-separated values.@CsvFileSource to use a CSV file from the classpath.@EnumSource to use enum constants.org.junit.jupiter.api.Assertions (e.g., assertEquals, assertTrue, assertNotNull).assertThat(...).is...).assertThrows or assertDoesNotThrow to test for exceptions.assertAll to ensure all assertions are checked before the test fails.@Mock and @InjectMocks annotations from Mockito to simplify mock creation and injection.@Tag to categorize tests (e.g., @Tag("fast"), @Tag("integration")).@TestMethodOrder(MethodOrderer.OrderAnnotation.class) and @Order to control test execution order when strictly necessary.@Disabled to temporarily skip a test method or class, providing a reason.@Nested to group tests in a nested inner class for better organization and structure.Weekly Installs
7.8K
Repository
GitHub Stars
26.9K
First Seen
Feb 25, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex7.7K
gemini-cli7.7K
opencode7.7K
cursor7.7K
github-copilot7.7K
kimi-cli7.7K
React 组合模式指南:Vercel 组件架构最佳实践,提升代码可维护性
102,200 周安装