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>
1.3 KiB
1.3 KiB
ModbusPal simulator profiles
Drop device-specific .xmpp profiles here. The integration tests connect to the
endpoint in MODBUS_SIM_ENDPOINT (default localhost:502) and expect the
simulator to already be running — tests do not launch ModbusPal themselves,
because its Java GUI + JRE requirement is heavier than the harness is worth.
Getting started
- Download ModbusPal from SourceForge (
modbuspal.jar). java -jar modbuspal.jarto launch the GUI.- Load a profile from this directory (or configure one manually) and start the simulator on TCP port 502.
dotnet test tests/ZB.MOM.WW.OtOpcUa.Driver.Modbus.IntegrationTests— tests auto-skip with a clearSkipReasonif the TCP probe at the configured endpoint fails within 2 seconds.
Profile files
DL205.xmpp— to be added — register map reflecting the AutomationDirect DL205 quirks tracked indocs/v2/modbus-test-plan.md. The scaffolded smoke test inDL205/DL205SmokeTests.csneeds holding register 100 writable and present; a minimal ModbusPal profile with a single holding-register bank at address 100 is sufficient.
Environment variables
MODBUS_SIM_ENDPOINT— override the simulator endpoint. Acceptshost:port; defaults tolocalhost:502. Useful when pointing the suite at a real PLC on the bench.