affaan-m avatar

Kotlin Testing

Covers the full TDD cycle in Kotlin with Kotest specs, MockK mocking, coroutine testing, and Kover coverage reporting. You get working examples of StringSpec, FunSpec, BehaviorSpec, and DescribeSpec styles, plus a proper RED-GREEN-REFACTOR walkthrough with an email validator. The matchers section is solid for assertions, and the MockK examples show coEvery for suspending functions and verification patterns. Includes Ktor testApplication setup if you're testing HTTP routes. The 80% coverage target with Kover is reasonable, and the examples are copy-paste ready. Good reference if you want idiomatic Kotlin tests instead of fighting with JUnit patterns that don't fit the language.

skills.sh installs
5.7K
GitHub stars
300.3K
last updated
Aug 21, 2026

Install

$ npx -y skills add affaan-m/ecc --skill kotlin-testing --agent claude-code

Installs into .claude/skills of the current project.

Files

Kotlin Testing Patterns

Comprehensive Kotlin testing patterns for writing reliable, maintainable tests following TDD methodology with Kotest and MockK.

When to Use

  • Writing new Kotlin functions or classes
  • Adding test coverage to existing Kotlin code
  • Implementing property-based tests
  • Following TDD workflow in Kotlin projects
  • Configuring Kover for code coverage

How It Works

  1. Identify target code — Find the function, class, or module to test
  2. Write a Kotest spec — Choose a spec style (StringSpec, FunSpec, BehaviorSpec) matching the test scope
  3. Mock dependencies — Use MockK to isolate the unit under test
  4. Run tests (RED) — Verify the test fails with the expected error
  5. Implement code (GREEN) — Write minimal code to pass the test
  6. Refactor — Improve the implementation while keeping tests green
  7. Check coverage — Run ./gradlew koverHtmlReport and verify 80%+ coverage

Examples

The following sections contain detailed, runnable examples for each testing pattern:

Quick Reference

Sponsors

Details

Repository
github.com/affaan-m/ecc
Categories
Testing & QA, Mobile Development, Java & JVM
First seen
Jul 14, 2026

More from affaan-m/ecc

All 263
1jeffallan avatartest-masterjeffallan/claude-skillsGenerates test files, creates mocking strategies, analyzes code coverage, designs test architectures, and produces test plans and defect reports across function5.7Kskills.sh installs
2jeffallan avatarplaywright-expertjeffallan/claude-skillsUse when writing E2E tests with Playwright, setting up test infrastructure, or debugging flaky browser tests. Invoke to write test scripts, create page objects,5.6Kskills.sh installs
3callstack avatarreact-native-testingcallstack/react-native-testing-libraryWrite tests using React Native Testing Library (RNTL) v13 and v14 (`@testing-library/react-native`). Use when writing, reviewing, or fixing React Native compone5.5Kskills.sh installs
4affaan-m avatarquarkus-tddaffaan-m/eccTest-driven development for Quarkus 3.x LTS using JUnit 5, Mockito, REST Assured, Camel testing, and JaCoCo. Use when adding features, fixing bugs, or refactori5.4Kskills.sh installs
5affaan-m avatarperl-testingaffaan-m/eccPerl testing patterns using Test2::V0, Test::More, prove runner, mocking, coverage with Devel::Cover, and TDD methodology.5.4Kskills.sh installs
6dotnet avatartest-anti-patternsdotnet/skillsAudits an existing test file or suite in any language for anti-patterns and quality issues — produces a severity-ranked report (Critical/Warning/Info). INVOKE w5.3Kskills.sh installs