Skip to content

test(e2e): add device-profiler register scanning tests#366

Open
groupsky wants to merge 2 commits intomainfrom
feat/e2e-device-profiler-tests
Open

test(e2e): add device-profiler register scanning tests#366
groupsky wants to merge 2 commits intomainfrom
feat/e2e-device-profiler-tests

Conversation

@groupsky
Copy link
Copy Markdown
Owner

@groupsky groupsky commented Feb 11, 2026

Summary

Adds comprehensive E2E test coverage for the device-profiler package (ya-modbus-profile command), which scans Modbus register ranges to discover readable/writable registers.

⚠️ Important: This tests packages/device-profiler (register scanning), NOT packages/cli (device discovery).

Test Coverage:

  • ✅ Basic register scanning - Holding and input registers
  • ✅ Batch size variations - Small (2) and large (20) batch sizes
  • ✅ Error handling - Non-existent registers, missing parameters, invalid slave IDs
  • ✅ Serial configuration - Baud rate and parity options
  • ✅ Output format - Progress messages and summary tables
  • ✅ Multiple devices - Scanning different slave IDs on same port
  • ✅ Resource cleanup - Proper cleanup after scans

Implementation Details:

  • Created tests/e2e/tests/05-device-profiler.bats with 19 new tests
  • Follows existing E2E test patterns from 04-cli.bats
  • Uses helper functions from helpers.bash
  • Tests the ya-modbus-profile CLI command (not ya-modbus discover)

What device-profiler does:
The device-profiler scans register address ranges to map which registers respond:

ya-modbus-profile --port /tmp/ttyV1 --slave-id 1 --type holding --start 0 --end 100

This is different from the CLI's discover command which finds devices on the bus.

Documentation Improvements:

  • Clarified fixture register ranges (sparse layout: 0-10, 42-43)
  • Explicitly documented that fixture has no input registers
  • Added context for hex value verification (register 0 = voltage field)

Verification:
All 102 E2E tests pass (83 existing + 19 new):

cd tests/e2e
./run-tests.sh
# 102 tests, 0 failures

Follow-Up Work

Coverage gaps identified and tracked in separate issues:

Test Plan

  • Run new device-profiler tests: ./run-tests.sh 05-device-profiler
  • Run full E2E test suite to verify no regressions
  • Verify tests scan registers correctly
  • Tests use existing fixtures and helper functions
  • Tests clean up resources in teardown
  • Documentation accurately describes test behavior

Addresses #239

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Feb 11, 2026

Open in StackBlitz

@ya-modbus/cli

npm i https://pkg.pr.new/@ya-modbus/cli@366

@ya-modbus/device-profiler

npm i https://pkg.pr.new/@ya-modbus/device-profiler@366

@ya-modbus/driver-ex9em

npm i https://pkg.pr.new/@ya-modbus/driver-ex9em@366

@ya-modbus/driver-loader

npm i https://pkg.pr.new/@ya-modbus/driver-loader@366

@ya-modbus/driver-or-we-516

npm i https://pkg.pr.new/@ya-modbus/driver-or-we-516@366

@ya-modbus/driver-sdk

npm i https://pkg.pr.new/@ya-modbus/driver-sdk@366

@ya-modbus/driver-types

npm i https://pkg.pr.new/@ya-modbus/driver-types@366

@ya-modbus/driver-xymd1

npm i https://pkg.pr.new/@ya-modbus/driver-xymd1@366

@ya-modbus/emulator

npm i https://pkg.pr.new/@ya-modbus/emulator@366

@ya-modbus/mqtt-bridge

npm i https://pkg.pr.new/@ya-modbus/mqtt-bridge@366

@ya-modbus/transport

npm i https://pkg.pr.new/@ya-modbus/transport@366

commit: 2be0135

Add comprehensive E2E tests for the ya-modbus-profile command which scans
Modbus register ranges to discover readable/writable registers.

Tests cover:
- Basic register scanning (holding and input registers)
- Batch size variations (small and large batches)
- Error handling (non-existent registers, invalid parameters)
- Serial port configuration (baud rate, parity)
- Output format verification (progress, summary table)
- Multiple device support (scanning different slave IDs)
- Resource cleanup verification

Includes 19 new tests bringing total E2E coverage to 102 tests.

NOTE: This tests packages/device-profiler (ya-modbus-profile command),
NOT packages/cli (ya-modbus discover command). The profiler scans register
address ranges to map device capabilities, while discover finds devices on
the bus.

Addresses #239
@groupsky groupsky force-pushed the feat/e2e-device-profiler-tests branch from 5339c43 to 072d457 Compare February 11, 2026 20:24
- Fix line 44: specify sparse register addresses (0-10, 42-43) not range
- Fix line 221: explicitly state fixture has no input registers
- Fix line 87: clarify hex value is from register 0 (voltage field)

These changes improve test maintainability by accurately documenting
fixture contents rather than using vague language.
@groupsky groupsky changed the title test(e2e): add device-profiler discovery tests test(e2e): add device-profiler register scanning tests Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant