Phase 3 PR 30 — Modbus integration-test project scaffold + DL205 smoke test #29

Merged
dohertj2 merged 1 commits from phase-3-pr30-modbus-integration-scaffold into v2 2026-04-18 15:08:46 -04:00
Owner

Scaffolds the integration-test harness docs/v2/modbus-test-plan.md called for. New project at tests/ZB.MOM.WW.OtOpcUa.Driver.Modbus.IntegrationTests/ with:

  • ModbusSimulatorFixture — TCP-probes MODBUS_SIM_ENDPOINT (default localhost:502) once per test session with a 2s timeout. Emits a clear SkipReason when unreachable; a collection fixture so the probe cost is amortized.
  • DL205/DL205Profile.cs — tag-map stub reflecting the first target device (AutomationDirect DL205). Writable holding register at address 100 (avoids the pending register-zero quirk). Probe loop disabled on the driver instance so background polls don't race assertions.
  • DL205/DL205SmokeTests.cs — one happy-path write → read round-trip exercising the real ModbusDriver + real ModbusTcpTransport. No quirk-specific assertions yet — those land one-per-PR as the user validates each behavior in ModbusPal.
  • ModbusPal/README.md — dev-loop instructions (install jar, load profile, start simulator, dotnet test) + MODBUS_SIM_ENDPOINT override doc for pointing at a real PLC on the bench. DL205.xmpp profile file is flagged as a follow-up PR alongside the first confirmed quirk.

Conventions honored

  • Tests call Assert.Skip(sim.SkipReason) (not silent return) — reads cleanly in CI logs.
  • DL205_ prefix on test names so --filter "DisplayName~DL205" surfaces device-specific failures.
  • Real transport, not fake — integration tests exist to catch wire-protocol issues the unit suite can't.
  • No cross-test state dependency: the smoke test writes before reading so ModbusPal's zero-on-start bank doesn't shape the result.

Test run

> dotnet test tests/ZB.MOM.WW.OtOpcUa.Driver.Modbus.IntegrationTests
Skipped! - Failed: 0, Passed: 0, Skipped: 1, Total: 1 — ZB.MOM.WW.OtOpcUa.Driver.Modbus.IntegrationTests.dll

SkipReason surfaces: 'Modbus simulator at localhost:502 did not accept a TCP connection within 2s. Start ModbusPal (or override MODBUS_SIM_ENDPOINT) and re-run.' Build clean — 0 warnings, 0 errors.

Next PRs

docs/v2/modbus-test-plan.md renumbered future quirk PRs to start at PR 31+. Each confirmed DL205 quirk gets one named test + any driver-side adjustment needed to pass it. Drop DL205.xmpp into ModbusPal/ alongside the first quirk PR.

Registered

ZB.MOM.WW.OtOpcUa.slnx lists the new project under tests/.

Scaffolds the integration-test harness `docs/v2/modbus-test-plan.md` called for. New project at `tests/ZB.MOM.WW.OtOpcUa.Driver.Modbus.IntegrationTests/` with: - **`ModbusSimulatorFixture`** — TCP-probes `MODBUS_SIM_ENDPOINT` (default `localhost:502`) once per test session with a 2s timeout. Emits a clear `SkipReason` when unreachable; a collection fixture so the probe cost is amortized. - **`DL205/DL205Profile.cs`** — tag-map stub reflecting the first target device (AutomationDirect DL205). Writable holding register at address 100 (avoids the pending register-zero quirk). Probe loop disabled on the driver instance so background polls don't race assertions. - **`DL205/DL205SmokeTests.cs`** — one happy-path write → read round-trip exercising the real `ModbusDriver` + real `ModbusTcpTransport`. No quirk-specific assertions yet — those land one-per-PR as the user validates each behavior in ModbusPal. - **`ModbusPal/README.md`** — dev-loop instructions (install jar, load profile, start simulator, `dotnet test`) + `MODBUS_SIM_ENDPOINT` override doc for pointing at a real PLC on the bench. `DL205.xmpp` profile file is flagged as a follow-up PR alongside the first confirmed quirk. ## Conventions honored - Tests call `Assert.Skip(sim.SkipReason)` (not silent return) — reads cleanly in CI logs. - `DL205_` prefix on test names so `--filter "DisplayName~DL205"` surfaces device-specific failures. - Real transport, not fake — integration tests exist to catch wire-protocol issues the unit suite can't. - No cross-test state dependency: the smoke test writes before reading so ModbusPal's zero-on-start bank doesn't shape the result. ## Test run ``` > dotnet test tests/ZB.MOM.WW.OtOpcUa.Driver.Modbus.IntegrationTests Skipped! - Failed: 0, Passed: 0, Skipped: 1, Total: 1 — ZB.MOM.WW.OtOpcUa.Driver.Modbus.IntegrationTests.dll ``` SkipReason surfaces: 'Modbus simulator at localhost:502 did not accept a TCP connection within 2s. Start ModbusPal (or override MODBUS_SIM_ENDPOINT) and re-run.' Build clean — 0 warnings, 0 errors. ## Next PRs `docs/v2/modbus-test-plan.md` renumbered future quirk PRs to start at PR 31+. Each confirmed DL205 quirk gets one named test + any driver-side adjustment needed to pass it. Drop `DL205.xmpp` into `ModbusPal/` alongside the first quirk PR. ## Registered `ZB.MOM.WW.OtOpcUa.slnx` lists the new project under `tests/`.
dohertj2 added 1 commit 2026-04-18 15:08:44 -04:00
ModbusSimulatorFixture is a collection fixture so the 2s TCP probe runs once per run, not per test; SkipReason gets a clear operator-facing message ('start ModbusPal or override MODBUS_SIM_ENDPOINT'). Tests call Assert.Skip(sim.SkipReason) rather than silently returning — matches the test-plan convention and reads cleanly in CI logs. DL205Profile.BuildOptions deliberately disables the background probe loop since integration tests drive reads explicitly and the probe would race with assertions. Tag naming uses the DL205_ prefix so filter 'DisplayName~DL205' surfaces device-specific failures at a glance.
Project references: xunit.v3 + Shouldly + Microsoft.NET.Test.Sdk + xunit.runner.visualstudio (matches the existing Driver.Modbus.Tests unit project), project ref to src/Driver.Modbus. Registered in ZB.MOM.WW.OtOpcUa.slnx under tests/. ModbusPal/README.md documents the dev loop (install ModbusPal jar, load profile, start simulator, dotnet test), explains MODBUS_SIM_ENDPOINT override for real-PLC benchwork, and flags DL205.xmpp as the first profile to add in a follow-up PR.
dotnet test run against the scaffold (no simulator running) skips cleanly: 0 failed, 0 passed, 1 skipped, with the SkipReason surfaced. dotnet build clean (0 warnings, 0 errors). Updated docs/v2/modbus-test-plan.md to mark the scaffold PR done and renumbered future PRs from 'PR 27+' to 'PR 31+' to stay in sync with the actual PR chain.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
dohertj2 merged commit d70a2e0077 into v2 2026-04-18 15:08:46 -04:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dohertj2/lmxopcua#29