Principle:APIJSON APIJSON Demo Automated Regression Testing
| 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:
- Schedule: Cron trigger fires
runScheduledApiRegression()at configured times - Ensure runner:
AutoTestNodeProcessSupervisor.ensureRunning()verifies Node.js APIAuto is alive - Start test: HTTP GET to
startUrlwith a unique key for session tracking - Poll status: Loop calling
statusUrl, parsingprogressandreportIdfrom JSON response - Detect completion:
progress >= 1.0or timeout - 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
- Implementation:APIJSON_APIJSON_Demo_AutoTestRegressionScheduler
- Implementation:APIJSON_APIJSON_Demo_AutoTestNodeProcessSupervisor
- Implementation:APIJSON_APIJSON_Demo_Server_JS
- Implementation:APIJSON_APIJSON_Demo_Diffview_JS
- Implementation:APIJSON_APIJSON_Demo_Difflib_JS
- Implementation:APIJSON_APIJSON_Demo_JSONResponse_JS