Skill

qtest-patterns

This skill should be used when the user asks to "write a test", "add tests to", "create a QTest", "how do I test a widget", "unit test for Qt", "pytest-qt", "test a PySide6 class", "QML test", "QtQuickTest", "write a test case", "test this class", or "generate a test file". Covers C++ QTest, Python pytest-qt, and QML TestCase patterns with CMake integration. Also activates for "write a C++ Qt test", "add a CMake test target", or "set up testlib".

From qt-suite
Install
1
Run in your terminal
$
npx claudepluginhub l3digitalnet/claude-code-plugins --plugin qt-suite
Tool Access

This skill uses the workspace's default tool permissions.

Supporting Assets
View in Repository
examples/calculator_test.cpp
examples/test_calculator.py
references/cpp-qtest.md
references/python-pytest-qt.md
references/qml-testcase.md
Skill Content

Qt Test Patterns

Qt testing spans three ecosystems: C++ QTest (native, zero dependencies), Python pytest-qt (PySide6 apps), and QML TestCase (QML component logic). This skill covers all three with CMake integration.

Choosing a Test Framework

ScenarioFramework
C++ Qt classes / business logicC++ QTest (QObject subclass + QTEST_MAIN)
PySide6 GUI applicationpytest + pytest-qt (qtbot fixture)
QML component behaviorQtQuickTest (TestCase QML type)
PySide6 non-GUI logicpytest (no pytest-qt needed)

Python / PySide6 with pytest-qt

Complete pytest-qt patterns — see references/python-pytest-qt.md for the full qtbot fixture API, signal waiting, conftest patterns, model testing, parametrize, async tests, and common gotchas.

Key config:

# pytest.ini
[pytest]
testpaths = tests
qt_api = pyside6

C++ QTest

Complete C++ QTest patterns — see references/cpp-qtest.md for the full macro reference, QSignalSpy, GUI/input simulation, benchmark macros, output formats, CMake patterns, and troubleshooting.

Key structure: each test class is a QObject subclass; private slots are test functions; QTEST_MAIN(ClassName) + #include "test_name.moc" at the end of the file.

QML TestCase

Complete QML TestCase patterns — see references/qml-testcase.md for the full assertion API, component creation, SignalSpy, async/timer testing, CMake setup, and common issues.

Key structure: TestCase QML item; test functions must start with test_; always call obj.destroy() to prevent leaks.

Additional Resources

Consult reference files in this skill's references/ directory for detailed patterns:

  • references/cpp-qtest.md — Full QTest macro reference, QSignalSpy, benchmark macros, output formats
  • references/python-pytest-qt.md — Complete pytest-qt fixture API, async patterns, model testing, common gotchas
  • references/qml-testcase.md — QML TestCase full API, async signal testing, component creation patterns

Working examples:

  • examples/test_calculator.py — Complete pytest-qt example with fixtures
  • examples/calculator_test.cpp — Complete C++ QTest example with data-driven tests
Stats
Parent Repo Stars3
Parent Repo Forks0
Last CommitMar 4, 2026