Test Driven Development (TDD) in Wikantik

Test Driven Development (TDD) is not just a practice in Wikantik; it is a mandatory mandate. As recorded in the repository's agent instructions (GEMINI.md and CLAUDE.md), a defect gets a test that demonstrates it before the fix is written, so we know the test actually detects the issue.

The TDD First Mandate

The core rule for all developers and AI agents is:

TDD First: Always write or update a test before fixing a bug or refactoring.

This ensures that:

  1. Requirements are clear: Writing the test forces a clear definition of what "success" looks like.
  2. Regressions are caught: The suite provides a safety net for future changes.
  3. Design is improved: Code that is hard to test is usually code that is poorly designed.

The Testing Pyramid

1. Unit Tests (Fast & Isolated)

Unit tests are JUnit 5 and live under each module's src/test. They target individual classes in isolation, which is made possible by the use of Stubs.

2. Integration Tests (Component Interplay)

Found in the wikantik-it-tests module and run only under the integration-tests profile, these tests verify that multiple modules work together correctly.

3. End-to-End Tests (User Flows)

Using Selenide, the project automates browser-based flows (login, page creation, admin actions) to ensure the React SPA and the Java backend are in sync. The browser runs headless by default.

TDD Workflow for AI Agents

  1. Research: Understand the current behavior and existing tests.
  2. Reproduction: Write a failing test case that demonstrates the bug or the missing feature, and run it to watch it fail — mvn test -pl <module> -Dtest=ClassName#methodName.
  3. Execution: Implement the minimal code change needed to make the test pass.
  4. Validation: Run the module's tests (mvn test -pl <module>) to ensure no regressions, then the canonical gate before committing: bin/run-tests.sh --parallel 4 (every unit test once, then the integration modules in parallel). Anything that can exceed about five minutes runs detached through bin/agent-build.sh.

See Also


Cluster Hub: Wikantik Platform Development Hub: Architecture, MCP Protocols, and Agent Briefings (wikantik-development)