integration

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 1, 2025 License: BSD-3-Clause Imports: 5 Imported by: 0

README

Integration Tests for Modbus Library

Overview

The integration tests are fully automated and require no external tools or manual setup. They use the built-in Modbus simulator located in internal/simulator/.

Running Tests

Simply run the tests directly:

# Run all integration tests
$ go test -v ./integration

# Run specific protocol tests
$ go test -v -run TCP ./integration
$ go test -v -run RTU ./integration
$ go test -v -run ASCII ./integration

How It Works

Each test automatically:

  1. Starts a Modbus simulator server (RTU, ASCII, or TCP)
  2. Creates a client connection
  3. Runs comprehensive function code tests
  4. Cleans up and stops the simulator

No external dependencies like diagslave or socat are needed!

Simulator CLI

You can also run the simulator standalone for manual testing:

# TCP mode
$ go run cmd/simulator/main.go -mode tcp -addr localhost:5020

# RTU mode
$ go run cmd/simulator/main.go -mode rtu -slave-id 17 -baud 19200

# ASCII mode
$ go run cmd/simulator/main.go -mode ascii -slave-id 17 -baud 19200

See cmd/simulator/main.go for all available options.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertEquals

func AssertEquals(t *testing.T, expected, actual interface{})

func ClientTestAll

func ClientTestAll(t *testing.T, client modbus.Client)

func ClientTestMaskWriteRegisters

func ClientTestMaskWriteRegisters(t *testing.T, client modbus.Client)

func ClientTestReadCoils

func ClientTestReadCoils(t *testing.T, client modbus.Client)

func ClientTestReadDiscreteInputs

func ClientTestReadDiscreteInputs(t *testing.T, client modbus.Client)

func ClientTestReadFIFOQueue

func ClientTestReadFIFOQueue(t *testing.T, client modbus.Client)

func ClientTestReadHoldingRegisters

func ClientTestReadHoldingRegisters(t *testing.T, client modbus.Client)

func ClientTestReadInputRegisters

func ClientTestReadInputRegisters(t *testing.T, client modbus.Client)

func ClientTestReadWriteMultipleRegisters

func ClientTestReadWriteMultipleRegisters(t *testing.T, client modbus.Client)

func ClientTestWriteMultipleCoils

func ClientTestWriteMultipleCoils(t *testing.T, client modbus.Client)

func ClientTestWriteMultipleRegisters

func ClientTestWriteMultipleRegisters(t *testing.T, client modbus.Client)

func ClientTestWriteSingleCoil

func ClientTestWriteSingleCoil(t *testing.T, client modbus.Client)

func ClientTestWriteSingleRegister

func ClientTestWriteSingleRegister(t *testing.T, client modbus.Client)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL