Skip to content

feat(test): add HTTP test client for integration testing#2099

Merged
bpamiri merged 5 commits intodevelopfrom
peter/http-test-client
Apr 15, 2026
Merged

feat(test): add HTTP test client for integration testing#2099
bpamiri merged 5 commits intodevelopfrom
peter/http-test-client

Conversation

@bpamiri
Copy link
Copy Markdown
Collaborator

@bpamiri bpamiri commented Apr 15, 2026

Summary

  • Adds TestClient.cfc — a fluent HTTP test client with chainable request methods (get, post, put, patch, delete, visit) and assertion methods (assertStatus, assertOk, assertSee, assertDontSee, assertJson, assertJsonPath, assertRedirect, assertHeader, assertCookie)
  • Adds visit() and $testClient() convenience methods to WheelsTest.cfc so test specs can write visit("/users").assertOk().assertSee("John")
  • Includes comprehensive BDD test spec in testClientSpec.cfc

Closes a gap vs Laravel's HTTP testing and Rails' integration tests identified in docs/wheels-vs-frameworks.md.

Test plan

  • Run bash tools/test-local.sh — all existing tests pass (zero regressions)
  • New tests in vendor/wheels/tests/specs/internal/testClientSpec.cfc pass
  • Verify TestClient works with actual HTTP requests against running server
  • Test across Lucee and Adobe CF engines

🤖 Generated with Claude Code

Adds a fluent HTTP test client inspired by Laravel's test helpers.
TestClient provides chainable request methods (get/post/put/patch/delete)
and assertion methods (assertStatus/assertSee/assertJson/etc.) for
writing concise integration tests. WheelsTest gains visit() and
$testClient() helpers.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
bpamiri and others added 4 commits April 14, 2026 21:51
- Fix cookie parsing bug: values containing '=' were truncated
  (ListToArray split on every '='; now uses Find/Mid for first '=' only)
- Make $makeRequest and $assertionError private (standalone CFC, not mixin)
- Remove redundant exact-match check in assertRedirect()
- Change assertJsonPath to 1-based array indexing (CFML convention)
- Rename 'client' variable to 'tc' in spec (CFML reserves 'client' scope)
- Remove silent-skip patterns: tests now assert preconditions or fail
- Add tests for put(), patch(), delete() methods
- Add tests for POST with body (form fields + JSON)
- Remove framework reload side effect from assertOk() test

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tests that called /wheels/core/tests from within the test runner
caused a thread pool deadlock on CI (single-threaded Lucee). Replaced
with $fakeClient() helper that sets internal response state directly,
allowing assertion logic to be tested without live HTTP calls to the
test endpoint. Live HTTP tests still use "/" which is safe.

Also adds $setFakeResponse() to TestClient for test isolation, and
improves assertSeeInOrder/assertJsonPath/assertRedirect coverage
using deterministic fake data instead of parsing live HTML responses.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Lucee 7 cannot resolve statusCode() as a method call when the
enclosing function has a parameter named statusCode — the parameter
shadows the method name. Renamed parameter to expectedStatus.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Root path (/) returns 500 during test runs because the framework
is mid-request. Use $fakeClient() for assertOk() and chaining
tests that depend on specific status codes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@bpamiri bpamiri merged commit 344b054 into develop Apr 15, 2026
3 checks passed
@bpamiri bpamiri deleted the peter/http-test-client branch April 15, 2026 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant