mirror of
https://github.com/jellyfin/jellyfin-desktop.git
synced 2026-10-26 16:45:24 +00:00
1.4 KiB
1.4 KiB
Contributing to Jellyfin Desktop
Running Tests
Jellyfin Desktop uses Qt Test for unit testing.
Building Tests
Tests are built automatically when you build the project:
cmake -B build
cmake --build build
Running Tests
Run all tests using CTest:
cd build
ctest
Or run individual test executables directly:
cd build
./tests/test_systemcomponent
Writing Tests
Tests are located in the tests/ directory. To add a new test:
- Create a test file in
tests/(e.g.,test_mycomponent.cpp) - Use
QTEST_APPLESS_MAINfor headless unit tests - Add the test to
tests/CMakeLists.txt
Example test structure:
#include <QtTest/QtTest>
#include "../src/mycomponent/MyComponent.h"
class TestMyComponent : public QObject
{
Q_OBJECT
private slots:
void testMyFunction_data();
void testMyFunction();
};
void TestMyComponent::testMyFunction_data()
{
QTest::addColumn<QString>("input");
QTest::addColumn<QString>("expected");
QTest::newRow("test case 1") << "input1" << "output1";
QTest::newRow("test case 2") << "input2" << "output2";
}
void TestMyComponent::testMyFunction()
{
QFETCH(QString, input);
QFETCH(QString, expected);
QString result = MyComponent::myFunction(input);
QCOMPARE(result, expected);
}
QTEST_APPLESS_MAIN(TestMyComponent)
#include "test_mycomponent.moc"
For more information on Qt Test, see the Qt Test documentation.