Skip to content

Instantly share code, notes, and snippets.

@jeje-andal
Created November 13, 2025 09:04
Show Gist options
  • Select an option

  • Save jeje-andal/4e8543d94942b0f10655097191e2aeae to your computer and use it in GitHub Desktop.

Select an option

Save jeje-andal/4e8543d94942b0f10655097191e2aeae to your computer and use it in GitHub Desktop.
TL;DR Summary: Salary Component Test Failures Root Cause and Solution

TL;DR: Salary Component Test Failures Root Cause

Problem

Salary Component tests fail intermittently because they use hard-coded names ("Uang Bensin", "Uang Denda Harian") that conflict with existing data from previous runs.

Failure Pattern

  • Run 1: Create & Edit fail (names already exist), Delete succeeds
  • Run 2: Edit succeeds (target name now available), Delete succeeds
  • Run 3: All succeed (system finally clean)

Root Cause

Tests have sequential dependencies and no automated cleanup:

  • Scenario 001: Creates "Uang Bensin"
  • Scenario 002: Edits "Uang Bensin" → "Uang Denda Harian" (UPDATE)
  • Scenario 003: Deletes "Uang Denda Harian"

Solution

Implement test independence with dynamic data:

// Generate unique names
$"Test_Salary_{DateTime.Now:yyyy-MM-dd_HH-mm-ss}_{Guid.NewGuid():N}"

Key Changes Needed

  1. Dynamic test data (eliminate hard-coded names)
  2. AfterScenario cleanup hooks (automated data deletion)
  3. Self-contained scenarios (each creates its own test data)
  4. BeforeScenario validation (ensure clean starting state)

Benefits

✅ Tests run in any order ✅ Parallel execution support ✅ Reliable, consistent results ✅ Easy debugging and maintenance

Implementation Time

  • Phase 1: 1-2 days (basic fixes)
  • Phase 2: 3-5 days (robust implementation)
  • Phase 3: 1 week (full independence)

Full analysis: https://gist.github.com/jeje-andal/af0c21bfab9cdec4056cc170f7d84fbf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment