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.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "qt test patterns" with this command: npx skills add l3digital-net/claude-code-plugins/l3digital-net-claude-code-plugins-qt-test-patterns

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

Scenario Framework

C++ Qt classes / business logic C++ QTest (QObject subclass + QTEST_MAIN )

PySide6 GUI application pytest + pytest-qt (qtbot fixture)

QML component behavior QtQuickTest (TestCase QML type)

PySide6 non-GUI logic pytest (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

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

qt-qml

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

qt-architecture

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

qt-packaging

No summary provided by upstream source.

Repository SourceNeeds Review