Commit 60bcc53
test(#889): McpServer lifecycle invariants — url/isRunning/stop/chainability
The existing tests cover error-path response codes (`McpServerErrorPathsTest`,
`McpServerConformanceTest`) but never exercise the lifecycle state machine
itself — `url` getter on an unstarted server, `isRunning()` transitions,
`stop()` idempotency, `start()` chainability.
Eight new tests target one specific mutant each:
- `url` throws with "not started" message when never started (kills the
`error("McpServer not started")` removal mutant at McpServer.kt:82).
- `isRunning()` flips false→true on start, true→false on stop (catches
always-true/always-false mutants on the boolean accessor).
- `url` re-throws after stop (verifies `http = null` actually happens in
`stop()`, not just `http?.stop(0)` being called).
- `start()` returns `this` (chainability — `McpServer.from(...) { }.start()`
would otherwise compile but break at call sites).
- `stop()` called twice doesn't throw (idempotency — catches mutants
that would make the second call NPE).
- `url` shape contract: `http://localhost:<port>/mcp` with port > 0.
- Two `port = 0` servers get distinct OS-assigned ports (proves the
bind-to-zero path actually delegates to the OS rather than reusing a
cached port).
All eight pass on the current implementation. Together they kill ~6-8
PIT mutants in McpServer that the response-code tests can't reach
(McpServer.kt:82, :84-90, :93, :95 from the #889 cluster list).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 1129622 commit 60bcc53
1 file changed
Lines changed: 119 additions & 0 deletions
Lines changed: 119 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
0 commit comments