Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:APIJSON APIJSON Demo Automated Regression Testing

From Leeroopedia
Knowledge Sources
Domains Testing, DevOps, Automation
Last Updated 2026-10-14 00:00 GMT

Overview

Testing methodology that automatically runs API regression tests on a cron schedule, polling for completion, collecting results, and notifying stakeholders via email — without human intervention.

Description

Automated Regression Testing in APIJSON uses a cron-scheduled Spring service to trigger APIAuto test runs against the live server. The scheduler starts the test, polls for completion, collects the report, and sends an HTML email summary. A separate process supervisor ensures the Node.js test runner (APIAuto) is always running.

This solves:

  • Manual test burden: Without automation, regression testing requires manual execution after every deployment.
  • Late detection: Scheduled runs catch regressions early, before users encounter them.
  • Process reliability: The Node.js test runner might crash; the supervisor automatically restarts it.

The testing pipeline:

  1. Schedule: Cron trigger fires runScheduledApiRegression() at configured times
  2. Ensure runner: AutoTestNodeProcessSupervisor.ensureRunning() verifies Node.js APIAuto is alive
  3. Start test: HTTP GET to startUrl with a unique key for session tracking
  4. Poll status: Loop calling statusUrl, parsing progress and reportId from JSON response
  5. Detect completion: progress >= 1.0 or timeout
  6. Notify: Send HTML email with start/end time, duration, progress, report URL

Usage

Use this principle when:

  • Building CI/CD pipelines that need scheduled API regression checks.
  • You want test result notifications without integrating a full CI system.
  • The test runner is a separate process that needs lifecycle management.

Theoretical Basis

Scheduling:
    @Scheduled(cron = "0 0 10,20 * * *", zone = "Asia/Shanghai")
    → fires at 10:00 and 20:00 every day

Concurrency Control:
    AtomicBoolean running
    → compareAndSet(false, true) prevents overlapping runs

Polling Loop:
    deadline = now + timeoutMinutes * 60_000
    while (now < deadline):
        response = HTTP GET statusUrl
        progress = parse(response).progress
        if progress >= 1.0: break
        sleep(pollIntervalMillis)

Timeout Handling:
    if progress < 1.0 after deadline:
        result.errorMessage = "Polling timeout"

Configuration via @Value injection:

Property Default Description
apijson.auto-test.enabled true Master toggle
apijson.auto-test.cron 0 0 10,20 * * * Cron schedule
apijson.auto-test.poll-interval-millis 15000 Polling delay
apijson.auto-test.timeout-minutes 180 Max test duration
apijson.auto-test.mail.to (empty) Email recipients

Related Pages

Implemented By

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment