test-rules

Guide Kotlin unit tests with given-when-then, AssertJ, and Kotest.

Updated Jan 11, 2026
One-click install
npx skills add https://github.com/gykk16/spring-skeleton --skill test-rules
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-rules
Source: https://github.com/gykk16/spring-skeleton/tree/main/.omc/skills/test-rules
Command: npx skills add https://github.com/gykk16/spring-skeleton --skill test-rules

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides clear, actionable guidelines and best practices for writing effective unit tests, ensuring consistency and quality in your test suite.

Core Features & Use Cases

  • Standardized Test Structure: Enforces the given-when-then pattern for readability.
  • Assertion Libraries: Guides on using AssertJ and Kotest effectively.
  • Test Quality: Emphasizes writing meaningful tests that validate behavior, not just coverage.
  • Use Case: When you need to write a new test for a complex business logic method, consult this Skill to ensure your test is well-structured, uses appropriate assertions, and covers critical scenarios.

Quick Start

Follow the given-when-then structure and use AssertJ for assertions when writing new tests.

Frequently Asked Questions about test-rules

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

FAQPage Schema
How do I structure unit tests in Kotlin for better readability?

Use the given-when-then pattern to structure Kotlin unit tests, clearly separating setup, execution, and assertions. This standardized approach improves readability and maintainability by enforcing a logical flow for validating complex business logic.

What is the best way to write assertions in Kotlin using AssertJ and Kotest?

Write assertions in Kotlin using AssertJ and Kotest to validate behavior effectively rather than just achieving coverage. These libraries provide fluent assertion methods that generate descriptive error messages, ensuring meaningful test quality and precise failure identification.

How do I name unit tests and organize them using nested classes?

Name unit tests to clearly describe the validated behavior and organize them using nested classes to group related scenarios. This practice ensures consistency across your test suite and makes complex test structures easier to navigate and understand.

Can I use Mockito-Kotlin and MockK for mocking strategies in unit tests?

Yes, you can use Mockito-Kotlin and MockK for mocking strategies in unit tests. These libraries help isolate dependencies and simulate external behaviors, ensuring your tests focus purely on validating the specific business logic under test.

When do I need comprehensive guidelines for writing unit tests?

You need comprehensive guidelines for writing unit tests when developing complex business logic methods to ensure your tests are well-structured. Following these best practices guarantees consistent quality, appropriate assertions, and coverage of critical scenarios across the suite.