Skip to content

Commit 380e5ca

Browse files
authored
Write unit-tests (#480)
* Write unit-tests * Fix CI/CD for Windows unit-tests * Restore commented code * Update development.rst * Remove unused files * Chesk signal spy instances * Add data flow test * Fix
1 parent ddb5498 commit 380e5ca

43 files changed

Lines changed: 2929 additions & 716 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/cmake_build.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ jobs:
6969

7070
- name: Setup (Linux)
7171
if: startsWith (matrix.os, 'ubuntu')
72-
run: sudo apt-get install libxkbcommon-dev
72+
run: |
73+
sudo apt-get update
74+
sudo apt-get install libxkbcommon-dev xvfb
7375
7476
- name: Setup VS tools (Windows)
7577
if: startsWith (matrix.os, 'windows')
@@ -82,3 +84,21 @@ jobs:
8284

8385
- name: Build with ${{ matrix.compiler }}
8486
run: cmake --build build --config ${{ matrix.configuration }}
87+
88+
- name: Run Tests (Linux)
89+
if: startsWith (matrix.os, 'ubuntu')
90+
run: |
91+
cd build
92+
xvfb-run -a ctest --output-on-failure --progress
93+
94+
- name: Run Tests (macOS)
95+
if: startsWith (matrix.os, 'macos')
96+
run: |
97+
cd build
98+
ctest --output-on-failure --progress
99+
100+
- name: Run Tests (Windows)
101+
if: startsWith (matrix.os, 'windows')
102+
run: |
103+
cd build
104+
ctest -C ${{ matrix.configuration }} --output-on-failure --progress

.travis.yml

Lines changed: 0 additions & 59 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ set(CMAKE_DISABLE_SOURCE_CHANGES ON)
1313
set(OpenGL_GL_PREFERENCE LEGACY)
1414
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
1515

16+
# Enable AUTOMOC globally for all targets (needed for examples with Q_OBJECT)
17+
set(CMAKE_AUTOMOC ON)
18+
set(CMAKE_AUTORCC ON)
19+
1620
get_directory_property(_has_parent PARENT_DIRECTORY)
1721
if(_has_parent)
1822
set(is_root_project OFF)
@@ -30,8 +34,6 @@ option(BUILD_DEBUG_POSTFIX_D "Append d suffix to debug libraries" OFF)
3034
option(QT_NODES_FORCE_TEST_COLOR "Force colorized unit test output" OFF)
3135
option(USE_QT6 "Build with Qt6 (Enabled by default)" ON)
3236

33-
enable_testing()
34-
3537
if(QT_NODES_DEVELOPER_DEFAULTS)
3638
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
3739
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
@@ -191,12 +193,6 @@ set_target_properties(QtNodes
191193
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
192194
)
193195

194-
######
195-
# Moc
196-
##
197-
set_target_properties(QtNodes PROPERTIES AUTOMOC ON AUTORCC ON)
198-
199-
200196
###########
201197
# Examples
202198
##
@@ -212,9 +208,11 @@ endif()
212208
##################
213209
# Automated Tests
214210
##
211+
enable_testing()
212+
215213

216214
if(BUILD_TESTING)
217-
#add_subdirectory(test)
215+
add_subdirectory(test)
218216
endif()
219217

220218
###############

README.rst

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,13 @@ Qt Creator
136136
----------
137137

138138
1. Open `CMakeLists.txt` as project.
139-
2. If you don't have the `Catch2` library installed, go to `Build Settings`, disable the checkbox `BUILD_TESTING`.
140-
3. `Build -> Run CMake`
141-
4. `Build -> Build All`
142-
5. Click the button `Run`
139+
2. `Build -> Run CMake`
140+
3. `Build -> Build All`
141+
4. Click the button `Run`
142+
143+
.. note::
144+
The project includes unit tests built with Catch2. If you don't have Catch2 installed,
145+
you can disable testing by setting `-DBUILD_TESTING=OFF` in CMake configuration.
143146

144147

145148
With Cmake using `vcpkg`
@@ -153,6 +156,39 @@ With Cmake using `vcpkg`
153156
-DCMAKE_TOOLCHAIN_FILE=<vcpkg_dir>/scripts/buildsystems/scripts/buildsystems/vcpkg.cmake
154157

155158

159+
Testing
160+
=======
161+
162+
QtNodes includes a comprehensive unit test suite built with Catch2.
163+
164+
**Running Tests**
165+
166+
From the build directory:
167+
168+
::
169+
170+
# Build tests
171+
make test_nodes
172+
173+
# Run all tests
174+
./bin/test_nodes
175+
176+
# Run specific categories
177+
./bin/test_nodes "[core]" # Core functionality tests
178+
./bin/test_nodes "[graphics]" # Graphics system tests
179+
180+
**Test Coverage**
181+
182+
* Core model operations (node CRUD, connections)
183+
* Signal emission verification (AbstractGraphModel signals)
184+
* Serialization (JSON save/load)
185+
* Undo system integration
186+
* Graphics scene management
187+
* Connection utilities
188+
189+
For detailed testing documentation, see the `Testing Guide <https://qtnodes.readthedocs.io/en/latest/testing.html>`_.
190+
191+
156192
Help Needed
157193
===========
158194

docs/development.rst

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,19 @@ Development Progress
77
- [✅ done] Dynamic ports
88
- [✅ done] ``AbstractNodeGeometry``, ``AbstractNodePainter``
99
- [✅ done] Website with documentation
10-
- [✅] ``ConnectionPaintDelegate``
11-
- [➡️ work in progress] Unit-Tests
12-
- [➡️ work in progress] Ctrl+D for copying and inserting a selection duplicate
10+
- [✅ done] ``ConnectionPaintDelegate``
11+
- [✅ done] Unit-Tests
12+
- [✅ done] Ctrl+D for copying and inserting a selection duplicate
1313
- [⏸ not started] Node groups
1414
- [⏸ not started] Check how styles work and what needs to be done. See old pull-requests
1515
- [☝ help needed] Python bindings. Maybe a wrapper using Shiboken
1616
- Python examples
1717
- [☝ help needed] QML front-end
1818

19+
20+
Testing
21+
=======
22+
23+
QtNodes includes a comprehensive unit test suite. For detailed information about
24+
running tests, test coverage, and implementation details, see :doc:`testing`.
25+

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ QtNodes Documentation
1010
features
1111
porting
1212
development
13+
testing
1314
classes
1415
notes
1516
license_link

0 commit comments

Comments
 (0)