Files
leocad/tests/README.md
T
Leonardo Zide baae697960 Fix in-place submodel editing context and navigation
In-place editing could use the tab model's step and focus, lose its active
state after switching tabs, or resolve a nested instance through the wrong
parent. Entering before the final animation key also moved geometry when
drilling into a child.

Use the edited model for step controls, step edits, visibility, and focus
coordinates. Restore that editing target when returning to its tab, include
animation keys and finite hide steps in the last step, and retain the
selected instance path and transforms during nested editing.

Show the editing path only during in-place edits, with links to ancestors
and a close control to return to the tab model. Stack Find/Replace beneath
it and preserve full names in accessible text and tooltips. Add translated
source entries without changing existing translations.

Add a regression test for final-key tracking through time and key edits.
Validated with the macOS Qt 6 application build, all 8 Qt Test cases, and
51 focused checks against the compiled application for steps, tab switching,
focus status, breadcrumbs, and Find/Replace layout. Visually checked the
viewport overlay and its placement during nested editing.
2026-10-24 12:39:25 -07:00

76 lines
2.7 KiB
Markdown

# LeoCAD tests
All tests run in one Qt Test executable, `leocad_tests`. The current tests cover
object history, property-key comparisons, and the final animation key after
step insertion, removal, and key deletion, including 8,000 deterministic
randomized undo/redo and merge transitions.
The executable creates a `QCoreApplication`; it does not open windows or require
an OpenGL context, the parts library, or network access. It uses the same Qt
headers as the application, plus Qt Test, and supports Qt 5 and Qt 6.
## Build and run
From the repository root, with the intended Qt installation's `qmake` on PATH:
```sh
mkdir -p build/tests
cd build/tests
qmake ../../tests/tests.pro CONFIG+=release CONFIG-=debug
make -j
make check
```
On Windows, use the make tool for the selected Qt kit, such as `nmake`.
To list test functions or run one function directly:
```sh
./leocad_tests -functions
./leocad_tests HistoryStoresOnlyChangedObjects
```
On Windows, the executable is `leocad_tests.exe` and may be in `release/`.
`make check` handles the configured executable location.
To write both console output and a JUnit report:
```sh
make check TESTARGS="-o test-results.xml,junitxml -o -,txt"
```
## Add tests
1. Declare a named `void` function under `private slots` in `lc_tests.h`.
2. Define it in the relevant test source file as `void lcTests::FunctionName()`.
3. If adding a new source file, list it in `tests.pro`.
Use `QVERIFY`, `QCOMPARE`, or other Qt Test checks so assertions remain active in
release builds and failures identify the function and source line. Each test
must create its own state. Use temporary directories for writable fixtures and
fixed seeds for randomized tests; include the seed and iteration in failures.
Tests should call production code directly.
Application-level tests needing more source files should declare those sources
and dependencies in `tests.pro`; shared source lists can move into `.pri` files
when needed. Keep application startup and packaging out of the test target.
## GitHub CI
`.github/workflows/continuous.yml` builds and runs this target on Linux (Qt 5),
macOS (Qt 6), and Windows x64 (Qt 6 with MSVC 2022), on pull requests to `master`,
pushes to `master`, and manual runs. JUnit reports are uploaded as artifacts,
including on test failure. Adding a test does not require changing the workflow
or `main.cpp`.
The Windows job uses `nmake` and a single release configuration. To reproduce its
commands in an x64 MSVC developer command prompt with Qt on PATH:
```bat
mkdir build\tests
cd build\tests
qmake ..\..\tests\tests.pro -spec win32-msvc CONFIG+=release CONFIG-=debug CONFIG-=debug_and_release
nmake /NOLOGO
nmake /NOLOGO check "TESTARGS=-o test-results.xml,junitxml -o -,txt"
```