sailfish-unit-testslisted
Install: claude install-skill teekesti/sailfish-agent-skills
# Sailfish OS unit tests (Qt Test via sfdk)
Tests must be compiled and *run* inside the SDK's build engine, using one of its
targets (see the `sailfish-sdk` skill for why the host's own Qt/`qmake`/`g++`
can't be substituted). This skill sets that up once per project and gives a
repeatable shadow-build workflow.
## 0. Locate the SDK and pick a target
Use the `sailfish-sdk` skill to find the SDK install, list/pick a target, and
run `sfdk config --global target=...` + `sfdk build-init` for this project.
Pick the **i486** target specifically — it's the only architecture that runs
*natively* on an x86_64 host inside the build engine, so the compiled test
binary can be executed directly without a device/emulator.
## 1. Install the QtTest dev package
Check first, it's usually absent even though the runtime `qt5-qttest` package
is present:
```bash
$SFDK build-shell rpm -qa | grep qttest-devel || \
$SFDK build-shell --maintain zypper -n install qt5-qttest-devel
```
## 2. Identify what's testable vs. what needs a seam
C++ classes that are pure logic/state (no Sailfish-specific APIs) can be compiled
and linked directly into the test binary — find them by grepping `src/` for
`#include <sailfishapp.h>`, `QSoundEffect`, `Sailfish::`, or similar platform-only
includes.
For a class that *is* testable but whose constructor unconditionally creates a
dependency you can't satisfy in tests (e.g. a `SoundPlayer` needing an audio
backend, or anything using `SailfishApp::pathTo()`), the low