qt-test-fixture-generator
БесплатноБез исполняемых скриптовНе проверенGenerate Qt Test fixtures with mock QObject signals and slots, data-driven tests, and GUI testing setup
от a5c-ai★ 1 947 звёзд на GitHubОб этом скилле
qt-test-fixture-generator
Generate Qt Test fixtures with mock QObject signals and slots, data-driven tests, and GUI testing setup. This skill creates comprehensive test infrastructure for Qt applications.
Capabilities
- Generate QTest-based test fixtures
- Create mock QObjects with signal/slot support
- Set up data-driven tests with QFETCH
- Configure GUI testing with QTestLib
- Generate test doubles for Qt classes
- Set up benchmark tests
- Configure test coverage reporting
- Generate CMake test integration
Input Schema
{
"type": "object",
"properties": {
"projectPath": {
"type": "string",
"description": "Path to the Qt project"
},
"classToTest": {
"type": "string",
"description": "Name of the class to generate tests for"
},
"testType": {
"enum": ["unit", "integration", "gui", "benchmark"],
"default": "unit"
},
"mockDependencies": {
"type": "array",
"items": { "type": "string" },
"description": "Classes to mock"
},
"dataProviders": {
"type": "array",
"items": {
"type": "object",
"properties": {
"testName": { "type": "string" },
"columns": { "type": "array" },
"rows": { "type": "array" }
}
}
},
"generateCoverage": {
"type": "boolean",
"default": true
}
},
"required": ["projectPath", "classToTest"]
}
Output Schema
{
"type": "object",
"properties": {
"success": { "type": "boolean" },
"files": {
"type": "array",
"items": {
"type": "object",
"properties": {
"path": { "type": "string" },
"type": { "enum": ["test", "mock", "cmake"] }
}
}
},
"runCommand": { "type": "string" }
},
"required": ["success"]
}
Generated Test Fixture
// tst_mywidget.cpp
#include <QtTest/QtTest>
#include <QSignalSpy>
#include "mywidget.h"
#include "mockservice.h"
class tst_MyWidget : public QObject
{
Q_OBJECT
private slots:
// Test lifecycle
void initTestCase(); // Before all tests
void cleanupTestCase(); // After all tests
void init(); // Before each test
void cleanup(); // After each test
// Unit tests
void testConstructor();
void testSetValue();
void testSetValue_data(); // Data provider
void testSignalEmission();
// GUI tests
void testButtonClick();
void testKeyboardInput();
// Benchmark
void benchmarkCalculation();
private:
MyWidget* m_widget;
MockService* m_mockService;
};
void tst_MyWidget::initTestCase()
{
// One-time setup
qDebug() << "Starting MyWidget tests";
}
void tst_MyWidget::cleanupTestCase()
{
// One-time cleanup
}
void tst_MyWidget::init()
{
// Create fresh instances for each test
m_mockService = new MockService(this);
m_widget = new MyWidget(m_mockService);
}
void tst_MyWidget::cleanup()
{
delete m_widget;
delete m_mockService;
m_widget = nullptr;
m_mockService = nullptr;
}
void tst_MyWidget::testConstructor()
{
QVERIFY(m_widget != nullptr);
QCOMPARE(m_widget->value(), 0);
QVERIFY(m_widget->isEnabled());
}
void tst_MyWidget::testSetValue_data()
{
// Data-driven test setup
QTest::addColumn<int>("input");
QTest::addColumn<int>("expected");
QTest::addColumn<bool>("shouldEmitSignal");
QTest::newRow("zero") << 0 << 0 << false;
QTest::newRow("positive") << 42 << 42 << true;
QTest::newRow("negative") << -10 << -10 << true;
QTest::newRow("max") << INT_MAX << INT_MAX << true;
}
void tst_MyWidget::testSetValue()
{
// Fetch test data
QFETCH(int, input);
QFETCH(int, expected);
QFETCH(bool, shouldEmitSignal);
QSignalSpy spy(m_widget, &MyWidget::valueChanged);
m_widget->setValue(input);
QCOMPARE(m_widget->value(), expected);
QCOMPARE(spy.count(), shouldEmitSignal ? 1 : 0);
}
void tst_MyWidget::testSignalEmission()
{
QSignalSpy spy(m_widget, &MyWidget::valueChanged);
QVERIFY(spy.isValid());
m_widget->setValue(100);
QCOMPARE(spy.count(), 1);
QList<QVariant> arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toInt(), 100);
}
void tst_MyWidget::testButtonClick()
{
// GUI testing
QPushButton* button = m_widget->findChild<QPushButton*>("submitButton");
QVERIFY(button != nullptr);
QSignalSpy spy(m_widget, &MyWidget::submitted);
QTest::mouseClick(button, Qt::LeftButton);
QCOMPARE(spy.count(), 1);
}
void tst_MyWidget::testKeyboardInput()
{
QLineEdit* input = m_widget->findChild<QLineEdit*>("nameInput");
QVERIFY(input != nullptr);
input->setFocus();
QTest::keyClicks(input, "Hello World");
QCOMPARE(input->text(), QString("Hello World"));
// Test keyboard shortcut
QTest::keyClick(m_widget, Qt::Key_S, Qt::ControlModifier);
// Verify save action triggered
}
void tst_MyWidget::benchmarkCalculatio
Установить qt-test-fixture-generator в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadWriteEditBashGlobGrepВложенные файлы
FAQ
Что делает скилл qt-test-fixture-generator?
Generate Qt Test fixtures with mock QObject signals and slots, data-driven tests, and GUI testing setup
Как установить скилл qt-test-fixture-generator?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл qt-test-fixture-generator запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic