Repository navigation
refactor: replace repetitive command/query integration tests with mock harness tests - #189
Merged
Merged
Conversation
…k harness tests Most command and query integration tests started a Mosquitto container and simulated the backend over MQTT, although the extension functions under test are thin wrappers around sendCommandAsync/queryListAsync. - add MockedXesarConnect test harness (mocked MqttAsyncClient, recorded publishes, responders simulating the backend) - convert 94 command/query integration tests into harness tests in command/ and query/ with unchanged calls, events, assertions and expected payloads - keep LockMediumTest, ChangeAuthorizationProfileTest and QueryCalendarTest as representative integration tests - rename RequestNewRegistrationCodeMapi test to RequestNewRegistrationCodeTest - assert the published payload for the "no result" medium identifier query - document the harness in CLAUDE.md Closes: #187 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #187.
Most command and query integration tests started a Mosquitto container and simulated the backend over MQTT. The extension functions they test are thin wrappers around
sendCommandAsync/queryListAsync, so MQTT transport, login and correlation were tested ~95 times.util/MockedXesarConnect: mockedMqttAsyncClient, published messages are recorded,respondTo(topic) { emitMessage(...) }simulates the backend. No Docker required.command/andquery/. Calls, events, assertions and expected JSON payloads are unchanged. Each test still checks the extension function wiring: topic, argument mapping into the command/query, and awaited events.it/command/LockMediumTest(single event),it/command/ChangeAuthorizationProfileTest(multiple events),it/query/QueryCalendarTest, plus the lifecycle/connection tests (ConnectAndLoginTest,MqttConnectionLostTest,ListenerTest,DelayUntilCloseTest,SubscribedTopicsTest,QueryStreamTest, …) andit/event/.RequestNewRegistrationCodeMapitest renamed toRequestNewRegistrationCodeTest.CLAUDE.mddocuments the harness.Unlike the issue's proposal (pure encoding/decoding tests), the harness keeps coverage of the extension function wiring.
Test plan
./gradlew spotlessApply testwith JDK 11: 269 tests pass🤖 Generated with Claude Code