skills/testing-skills/junit/SKILL.md
Provides comprehensive guidance for JUnit testing framework including test annotations, assertions, test lifecycle, and best practices. Use when the user asks about JUnit, needs to write Java unit tests, use JUnit annotations, or configure JUnit for Java projects.
npx skillsauth add partme-ai/full-stack-skills junitInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use this skill whenever the user wants to:
@Testimport org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class CalculatorTest {
@Test
void shouldAddTwoNumbers() {
Calculator calc = new Calculator();
assertEquals(5, calc.add(2, 3));
}
@Test
void shouldThrowOnDivideByZero() {
Calculator calc = new Calculator();
assertThrows(ArithmeticException.class, () -> calc.divide(1, 0));
}
}
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.AfterEach;
class UserServiceTest {
private UserService userService;
@BeforeEach
void setUp() {
userService = new UserService(new InMemoryUserRepository());
}
@AfterEach
void tearDown() {
// Clean up resources
}
}
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
class StringTest {
@ParameterizedTest
@CsvSource({"hello,5", "'',0", "junit,5"})
void shouldReturnCorrectLength(String input, int expected) {
assertEquals(expected, input.length());
}
}
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import static org.mockito.Mockito.*;
@ExtendWith(MockitoExtension.class)
class OrderServiceTest {
@Mock private OrderRepository orderRepository;
@InjectMocks private OrderService orderService;
@Test
void shouldSaveOrder() {
Order order = new Order("item-1", 2);
orderService.placeOrder(order);
verify(orderRepository).save(order);
}
}
# Maven
mvn test
# Gradle
gradle test
# With coverage (JaCoCo)
mvn test jacoco:report
shouldReturnEmptyListWhenNoUsersExist)@Nested classes to group related test casesjunit, JUnit 5, JUnit Jupiter, unit testing, Java, Kotlin, assertions, Mockito, parameterized tests, BeforeEach, AfterEach, test lifecycle
development
Provides per-component and per-API examples with cross-platform compatibility details for uni-app, covering built-in components, uni-ui components, and APIs (network, storage, device, UI, navigation, media). Use when the user needs official uni-app components or APIs, wants per-component examples with doc links, or needs platform compatibility checks.
tools
Creates new uni-app projects via the official CLI or HBuilderX with Vue 2/Vue 3 template selection, manifest.json and pages.json configuration, and directory structure setup. Use when the user wants to scaffold a new uni-app project, initialize project files with a single command, or set up the development environment.
tools
Browses, installs, configures, and manages plugins from the uni-app plugin market (ext.dcloud.net.cn) including component plugins, API plugins, and template plugins with dependency handling. Use when the user needs to find and install uni-app plugins, configure plugin settings, manage plugin dependencies, or integrate third-party components.
tools
Develops native Android and iOS plugins for uni-app including module creation, JavaScript-to-native communication, and plugin packaging for distribution. Use when the user needs to build custom native modules, extend uni-app with native capabilities (camera, Bluetooth, sensors), or create publishable native plugins.