Skip to content
This repository was archived by the owner on Mar 28, 2026. It is now read-only.

Latest commit

 

History

History
77 lines (54 loc) · 1.44 KB

File metadata and controls

77 lines (54 loc) · 1.44 KB

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:

  1. Create a test file in tests/ (e.g., test_mycomponent.cpp)
  2. Use QTEST_APPLESS_MAIN for headless unit tests
  3. 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.