Skip to content

Commit 029b384

Browse files
authored
refactor: consolidate and validate test files (#29)
* refactor: consolidate test files into organized structure - Organize all .http files under tests/ directory with subdirectories: - tests/e2e/: end-to-end integration tests (CI/CD) - tests/unit/: feature-specific unit tests - tests/examples/: documentation and showcase files - Consolidate 4 assertion test files into single tests/unit/assertions.http - Remove scattered examples/ directory at project root - Update all documentation references: - AGENTS.md: project structure, testing guidelines, examples - README.md: external-node-runtime and metrics-showcase paths - CLAUDE.md: metrics-showcase path - README-Testing.md: all test file paths and commands - docker-compose.yml: comprehensive-test.http path - tests/examples/external-node-runtime/README.md: all paths - Add tests/README.md with complete structure documentation - Keep testapi/*.http separate for test API development - Remove old test results from git tracking BREAKING CHANGE: Test file paths have moved. Update any external references to use new paths: tests/e2e/, tests/unit/, tests/examples/ * fix: correct .http format in assertions.http - Changed first line from '### Simple Assert Test' to '###' - The .http format requires ### separator alone on a line - Issue was introduced during test consolidation - Verified: assertions now execute correctly and test client.assert() functionality * docs: add test validation and execution reports - Add comprehensive validation report (static analysis) - Add execution test report with results - Document all APIs used and validated - Note fixed issue in assertions.http * docs: add comprehensive test validation summary * ci: add integration tests using consolidated test files - Add integration-test job that runs E2E tests - Tests comprehensive-test.http and toxiproxy-demo.http - Uses Docker Compose to start testapi and toxiproxy services - Validates new test file structure works in CI - semantic_release now depends on integration tests passing
1 parent 954b1fb commit 029b384

28 files changed

+863
-87
lines changed

.github/workflows/ci.yml

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,53 @@ jobs:
232232
git commit -m "chore(homebrew): update formulas for ${TAG}"
233233
git push origin "HEAD:${{ github.event.repository.default_branch }}"
234234
235+
integration-test:
236+
name: Integration Test
237+
needs: build
238+
runs-on: ubuntu-latest
239+
240+
steps:
241+
- name: Checkout code
242+
uses: actions/checkout@v4
243+
244+
- name: Set up Go
245+
uses: actions/setup-go@v4
246+
with:
247+
go-version: ${{ env.GO_VERSION }}
248+
249+
- name: Install dependencies
250+
run: make deps
251+
252+
- name: Build httprunner
253+
run: make build
254+
255+
- name: Start test services
256+
run: |
257+
docker compose up -d testapi toxiproxy
258+
echo "Waiting for services to be healthy..."
259+
sleep 30
260+
docker ps
261+
262+
- name: Run E2E comprehensive test
263+
run: |
264+
./build/httprunner \
265+
-f tests/e2e/comprehensive-test.http \
266+
-u 2 -i 3 \
267+
-report console -detail summary \
268+
-e <(echo "BASEURL=http://localhost:8080")
269+
270+
- name: Run E2E toxiproxy test
271+
run: |
272+
./build/httprunner \
273+
-f tests/e2e/toxiproxy-demo.http \
274+
-u 1 -i 2 \
275+
-report console -detail summary \
276+
-e <(echo "TOXIPROXY_URL=http://localhost:8081")
277+
278+
- name: Stop test services
279+
if: always()
280+
run: docker compose down -v
281+
235282
docker:
236283
name: Docker Build
237284
needs: test
@@ -279,7 +326,7 @@ jobs:
279326

280327
semantic_release:
281328
name: Semantic Release
282-
needs: [test, build]
329+
needs: [test, build, integration-test]
283330
runs-on: ubuntu-latest
284331
# Run only when a PR into develop is closed and merged (supports squash/rebase/merge)
285332
if: github.ref == 'refs/heads/develop' && github.event_name == 'push'

AGENTS.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
- `cmd/httprunner`: CLI to execute .http scenarios and produce reports.
55
- `cmd/harparser`: HAR → `.http` extractor tool.
66
- `parser`, `runner`, `reporting`, `metrics`, `http`, `template`: Core Go packages.
7-
- `tests`: End‑to‑end `.http` suites; `examples` contains smaller samples.
7+
- `tests`: All `.http` test files organized into `e2e/`, `unit/`, and `examples/` subdirectories.
88
- `testapi`, `docker-compose.yml`: Local test services (API + toxiproxy).
99
- `build/`, `results/` or `reports/`: Build artifacts and test outputs.
1010

@@ -14,7 +14,7 @@
1414
- `make dev` — fast local build without version ldflags.
1515
- `make test` / `make test-coverage` — run Go unit tests (all packages).
1616
- `make fmt` / `make lint` / `make check` — format, lint (if installed), run tests.
17-
- E2E: `./run-tests.sh` — spins up Docker services and runs `tests/*.http` with reports in `reports/`.
17+
- E2E: `./run-tests.sh` — spins up Docker services and runs `tests/e2e/comprehensive-test.http` with reports in `reports/`.
1818
- Docker: `docker compose up --profile runner httprunner` runs the comprehensive suite defined in compose.
1919

2020
## Coding Style & Naming
@@ -25,7 +25,7 @@
2525

2626
## Testing Guidelines
2727
- Unit tests: `_test.go`, functions `TestXxx(*testing.T)`. Run with `go test ./...`.
28-
- E2E: author `.http` files under `tests/`. Prefer environment placeholders (e.g., `{{.token}}`) and `.env` files.
28+
- E2E: author `.http` files under `tests/e2e/` or `tests/unit/`. Use `tests/examples/` for documentation. Prefer environment placeholders (e.g., `{{.token}}`) and `.env` files.
2929
- Coverage: keep critical packages (parser, runner, reporting) well covered; run `make test-coverage` locally.
3030

3131
## Commit & PR Guidelines
@@ -34,5 +34,5 @@
3434
- CI/readiness: ensure `make check` passes and `make build` succeeds; avoid committing generated artifacts in `build/` or `results/`.
3535

3636
## Tips & Utilities
37-
- Run `httprunner -f tests/comprehensive-test.http -u 5 -i 10 -d 50 -report html -output results` locally.
37+
- Run `httprunner -f tests/e2e/comprehensive-test.http -u 5 -i 10 -d 50 -report html -output results` locally.
3838
- Convert recordings: `harparser -f recording.har -filter api/v1 -o requests.http`.

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ if (!baseline) {
436436

437437
#### Complete Metrics Dashboard Example
438438

439-
See `examples/metrics-showcase.http` for a comprehensive example demonstrating:
439+
See `tests/examples/metrics-showcase.http` for a comprehensive example demonstrating:
440440
- Performance baseline establishment
441441
- Load pattern analysis
442442
- Error rate monitoring

README-Testing.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ This will:
7878
docker-compose up --build -d testapi toxiproxy
7979

8080
# Run specific test file
81-
docker-compose run --rm httprunner ./httprunner -u 3 -i 5 -f tests/comprehensive-test.http
81+
docker-compose run --rm httprunner ./httprunner -u 3 -i 5 -f tests/e2e/comprehensive-test.http
8282

8383
# Run with Toxiproxy simulation
84-
docker-compose run --rm httprunner ./httprunner -u 2 -i 3 -f tests/toxiproxy-demo.http
84+
docker-compose run --rm httprunner ./httprunner -u 2 -i 3 -f tests/e2e/toxiproxy-demo.http
8585

8686
# View logs
8787
docker-compose logs testapi
@@ -93,7 +93,7 @@ docker-compose down -v
9393

9494
## Test Files
9595

96-
### `tests/comprehensive-test.http`
96+
### `tests/e2e/comprehensive-test.http`
9797
Complete test suite demonstrating all HTTP Runner features:
9898
- ✅ Health checks
9999
- ✅ CRUD operations (Users, Products)
@@ -159,7 +159,7 @@ The included workflow (`.github/workflows/integration-test.yml`) will:
159159
```bash
160160
# High concurrency test
161161
docker-compose run --rm httprunner \
162-
./httprunner -u 50 -i 20 -d 100 -f tests/comprehensive-test.http \
162+
./httprunner -u 50 -i 20 -d 100 -f tests/e2e/comprehensive-test.http \
163163
--html-report reports/load-test.html
164164

165165
# Stress test with Toxiproxy
@@ -173,7 +173,7 @@ curl -X POST http://localhost:8474/proxies/testapi_proxy/toxics \
173173

174174
# 3. Run tests
175175
docker-compose run --rm httprunner \
176-
./httprunner -u 10 -i 50 -f tests/comprehensive-test.http
176+
./httprunner -u 10 -i 50 -f tests/e2e/comprehensive-test.http
177177
```
178178

179179
### Network Failure Simulation
@@ -188,11 +188,11 @@ curl -X POST http://localhost:8474/proxies/testapi_proxy/toxics \
188188

189189
### Adding New Endpoints
190190
1. Edit `testapi/main.go` to add new handlers
191-
2. Update `tests/comprehensive-test.http` with new test cases
191+
2. Update `tests/e2e/comprehensive-test.http` with new test cases
192192
3. Rebuild with `docker-compose build testapi`
193193

194194
### Custom Test Scenarios
195-
1. Create new `.http` files in the `tests/` directory
195+
1. Create new `.http` files in the `tests/e2e/` or `tests/unit/` directory
196196
2. Use the same format as existing files
197197
3. Reference environment variables with `{{.VARIABLE_NAME}}`
198198

@@ -221,7 +221,7 @@ docker-compose restart
221221
```bash
222222
# Run with verbose logging
223223
docker-compose run --rm httprunner \
224-
./httprunner -u 1 -i 1 -f tests/comprehensive-test.http -v
224+
./httprunner -u 1 -i 1 -f tests/e2e/comprehensive-test.http -v
225225

226226
# Check API directly
227227
curl http://localhost:8080/health

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ available on `PATH`; if it is missing or crashes, the CLI falls back to reportin
167167
When the flag is enabled, `httprunner` automatically adds any `node_modules` directories found next
168168
to the `.http` file (and up to two parent directories) to Node's resolution paths. For custom
169169
layouts, you can still extend `NODE_PATH` before launching the runner. See
170-
`examples/external-node-runtime` for a complete walkthrough.
170+
`tests/examples/external-node-runtime` for a complete walkthrough.
171171

172172
### Example requests.http
173173

@@ -375,7 +375,7 @@ if (!baseline) {
375375

376376
#### Complete Metrics Dashboard Example
377377

378-
See `examples/metrics-showcase.http` for a comprehensive example demonstrating:
378+
See `tests/examples/metrics-showcase.http` for a comprehensive example demonstrating:
379379
- Performance baseline establishment
380380
- Load pattern analysis
381381
- Error rate monitoring

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ services:
5858
command: >
5959
sh -c "
6060
echo 'Starting comprehensive test suite...' &&
61-
./httprunner -u 5 -i 10 -d 50 -f /requests/comprehensive-test.http -output /reports -detail summary -report html &&
61+
./httprunner -u 5 -i 10 -d 50 -f /requests/e2e/comprehensive-test.http -output /reports -detail summary -report html &&
6262
echo 'Test completed. Results saved in reports/'
6363
"
6464
networks:

0 commit comments

Comments
 (0)