Patrick Schurig c2eccd96e5 sunspec: add a failing test that sets up a Fronius connection
The existing suite only exercises free functions and the plugin JSON, so it
cannot see whether a thing class is dispatched at all. A thing class missing
from the dispatch in setupThing() falls into the final Q_ASSERT_X: in a debug
build the process dies, in a release build the assert is compiled out and
setupThing() returns without ever calling info->finish(), leaving the pairing
stuck with no message.

Split the tests into two suites. The logic one keeps its former scope and its
single dependency on libnymea-sunspec. The new one instantiates the plugin
behind the real ThingManager of libnymea-core and a faked HardwareManager, so
the dispatch of setupThing(), postSetupThing() and thingRemoved() is covered.
No network access takes place: the faked monitor is never reachable, so the
plugin never attempts a Modbus connection.

The four new cases fail: froniusConnection is not dispatched yet.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-01 16:18:41 +02:00

30 lines
930 B
Prolog

include(../../../sunspec.pri)
QT += testlib
QT -= gui
CONFIG += console testcase
CONFIG -= app_bundle
TEMPLATE = app
TARGET = tst_sunspec
# Suite de logique pure : ce que le plugin *decide*. Elle ne charge ni nymea ni
# le plugin lui-meme, et ne demande donc que libnymea-sunspec. La suite qui
# instancie reellement le plugin vit dans ../plugin/ et porte ses propres
# dependances. Ce qui est emis sur le bus releve du banc (voir "Non verifiable
# par les tests unitaires" dans specs/fronius-sunspec.md).
INCLUDEPATH += ../..
# Chemin du JSON de definition du plugin, pour les criteres qui portent sur les
# thingClasses et leurs plages de valeurs (AC-1, AC-7, AC-8, AC-10).
DEFINES += PLUGIN_JSON_PATH=\\\"$$PWD/../../integrationpluginsunspec.json\\\"
SOURCES += \
tst_sunspec.cpp \
../../sunspecstoragelogic.cpp \
../../froniusrules.cpp
HEADERS += \
../../sunspecstoragelogic.h \
../../froniusrules.h