You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add unit tests + cross-repo integration CI job (#4)
* add behavioural unit tests and cross-repo integration CI job
* convert unit tests to BDD style and drop compile-time arity tests
* fix RecordingListener onError signature to match 2-arg invocation
* improve onError test failure message to diagnose why events are empty or wrong
* drop onError-on-sync-connect test — nv-websocket-client throws without invoking listener in that path
* warm up extension before integration tests to avoid 404 race on first connect
- Scheme handling (`ws://`, `wss://`, rejection of `http://`)
11
+
- Connection error timing (refused-connection fails fast, unroutable IP hits the library's 5s timeout)
12
+
-`onError( type="connect", ... )` listener invocation on connect failure
13
+
- OSGi loader health
14
+
15
+
Runs in the `test` job via `lucee/script-runner@main` with `testLabels: websocketclient`. Fast, no network dependencies beyond loopback.
16
+
17
+
### Integration tests (server repo)
18
+
19
+
The real client⇄server coverage — `sendText`, `sendBinary`, `onMessage`, `onClose`, `disconnect`, `isOpen`, lifecycle event ordering — lives in the server extension repo:
Those tests use `CreateWebSocketClient` as the driver against a Lucee WebSocket server listener, so they cover both extensions end to end.
24
+
25
+
## Why not duplicate the integration tests here?
26
+
27
+
Every integration test needs both extensions running. Duplicating the suite across two repos guarantees drift. Instead:
28
+
29
+
- One copy lives in the server repo.
30
+
- The `test-integration` job in this repo's workflow **sparse-checkouts**`tests/integration/` from the server repo, builds this branch's client `.lex`, pulls the latest server `.lex` from download.lucee.org, and runs the suite against the combined pair.
31
+
- Each side's CI catches the bug on its own side — server changes fail in the server repo, client changes fail here.
32
+
33
+
## What fails where
34
+
35
+
| Bug source | Caught by |
36
+
| --- | --- |
37
+
| Client BIF contract (scheme handling, error shape, connection timing) | Unit tests in this repo |
| Server callback firing, broadcast, state | Integration tests (server repo CI) |
40
+
41
+
## Adding a test
42
+
43
+
Needs a server to drive it? **Add it to the server repo's [`tests/integration/`](https://github.com/lucee/extension-websocket/tree/master/tests/integration).** Both CIs will pick it up.
44
+
45
+
No server needed (argument validation, error shape, scheme parsing)? **Add a `testXxx()` method to [`WebSocketClientTest.cfc`](WebSocketClientTest.cfc) here.**
46
+
47
+
## Running locally
48
+
49
+
Unit tests — whatever CFML test runner you use that picks up `labels="websocketclient"`. Or invoke `WebSocketClientTest.cfc` methods directly from a test script.
50
+
51
+
Integration tests — spin up Lucee with both extensions, drop the server listeners into `{lucee-config}/websockets/`, and `curl` the `.cfm` scripts from the server repo's `tests/integration/` folder. See [that repo's CI workflow](https://github.com/lucee/extension-websocket/blob/master/.github/workflows/main.yml) for the exact setup — it's the same one this repo's `test-integration` job uses.
0 commit comments