writing-tests

Write JUnit 5 tests for IntelliJ codebases using fixtures and lifecycle annotations.

20.4k|6.0k|Updated Sep 30, 2011
One-click install
npx skills add https://github.com/JetBrains/intellij-community --skill writing-tests-jetbrains
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: writing-tests
Source: https://github.com/JetBrains/intellij-community/tree/main/.agents/skills/writing-tests
Command: npx skills add https://github.com/JetBrains/intellij-community --skill writing-tests-jetbrains

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Guidelines for writing tests in IntelliJ IDEA codebase. Use when creating new test classes or test methods.

Core Features & Use Cases

  • JUnit 5-first: Use @TestApplication instead of extending test case classes.
  • Shared fixtures: Use companion objects to hold project/module fixtures for reuse.
  • Lifecycle management: Use @BeforeAll, @AfterAll, @BeforeEach, and @AfterEach for setup and teardown; prefer @TestDisposable for disposable resources.
  • Run in EDT: Apply testing annotations to run tests in the EDT when required.
  • Showcase patterns: Refer to showcase tests and fixtures for concrete examples.

Quick Start

Create a new test class annotated with @TestApplication and follow the companion object fixture pattern to bootstrap tests.

Frequently Asked Questions about writing-tests

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write JUnit 5 tests for the IntelliJ codebase?

To write JUnit 5 tests for the IntelliJ codebase, annotate new test classes with @TestApplication instead of extending legacy test case classes, then use companion objects to hold shared project or module fixtures for reuse across test methods.

What is the best way to manage test fixtures and disposables in IntelliJ tests?

Managing test fixtures in IntelliJ tests involves holding shared project and module fixtures in companion objects. For disposable resources, apply the @TestDisposable annotation to ensure proper lifecycle handling and automated cleanup during test teardown.

How do I run tests in the EDT within the IntelliJ codebase?

To run tests in the Event Dispatch Thread (EDT) within the IntelliJ codebase, apply specific testing annotations designed to enforce EDT execution. This ensures UI-related test logic executes safely on the correct thread without manual invokeLater calls.

When should I use lifecycle annotations like BeforeAll and AfterEach for IntelliJ tests?

Use JUnit 5 lifecycle annotations like @BeforeAll, @AfterAll, @BeforeEach, and @AfterEach in IntelliJ tests to standardize setup and teardown operations. These annotations manage test state initialization and resource cleanup consistently across both Java and Kotlin codebases.

Can I use standard JUnit 5 patterns for registry and system properties in IntelliJ tests?

Standard JUnit 5 patterns for registry and system properties in IntelliJ tests require following specific codebase guidelines. The standardized approach specifies exact patterns for safely accessing and modifying registry entries and system properties during test execution.

Why standardize test structure with showcase patterns in IntelliJ?

Standardizing test structure with showcase patterns in IntelliJ ensures consistent test quality and practices across Kotlin and Java codebases. Referencing showcase tests provides concrete examples of proper fixture bootstrapping, lifecycle management, and EDT considerations.