Skip to content

Commit

Permalink
Add basic test
Browse files Browse the repository at this point in the history
  • Loading branch information
alcarazzam committed Nov 20, 2024
1 parent 943e562 commit 336b791
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 1 deletion.
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: None
# SPDX-License-Identifier: CC0-1.0

name: Build
name: Build & Test

on:
push:
Expand Down Expand Up @@ -35,3 +35,7 @@ jobs:
- name: Build
run: cmake --build build --parallel

- name: Test
run: ctest -T Test --output-on-failure --no-compress-output -j 4
working-directory: build

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ compile_commands.json
.flatpak-builder/
.idea/
cmake-build-*
*.log
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ include(FeatureSummary)
include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDECompilerSettings NO_POLICY_SCOPE)
include(ECMAddTests)

include(ECMSetupVersion)
include(ECMFindQmlModule)
Expand Down Expand Up @@ -52,6 +53,11 @@ ecm_find_qmlmodule(org.kde.kirigamiaddons.statefulapp)

add_subdirectory(src)

if(BUILD_TESTING)
find_package(Qt6 ${QT_MIN_VERSION} NO_MODULE COMPONENTS Test)
add_subdirectory(autotests)
endif()

install(FILES org.kde.chessament.desktop DESTINATION ${KDE_INSTALL_APPDIR})
install(FILES org.kde.chessament.metainfo.xml DESTINATION ${KDE_INSTALL_METAINFODIR})
ki18n_install(po)
Expand Down
11 changes: 11 additions & 0 deletions autotests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: 2024 Manuel Alcaraz Zambrano <[email protected]>
# SPDX-License-Identifier: BSD-3-Clause

enable_testing()

ecm_add_test(
tournamenttest.cpp
LINK_LIBRARIES chessament_static Qt::Test
TEST_NAME tournamenttest
)

26 changes: 26 additions & 0 deletions autotests/tournamenttest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-FileCopyrightText: 2024 Manuel Alcaraz Zambrano <[email protected]>
// SPDX-License-Identifier: GPL-3.0-or-later

#include <QObject>
#include <QString>
#include <QTest>

#include "tournament.h"

class TournamentTest : public QObject
{
Q_OBJECT

private Q_SLOTS:

void testNewTournament();
};

void TournamentTest::testNewTournament()
{
auto t = new Tournament();
QCOMPARE(t->name(), QStringLiteral(""));
}

QTEST_GUILESS_MAIN(TournamentTest)
#include "tournamenttest.moc"

0 comments on commit 336b791

Please sign in to comment.