KWin provides a unit and integration test suite for X11 and Wayland. The source code for the tests can be found in the subdirectory autotests. The test suite should be run prior to any merge to KWin.
The test suite can be run from the build directory. Best is to do:
cd path/to/build/directory
xvfb-run ctest
# Running individual tests
All tests executables are created in the directory "bin" in the build directory. Each test can be executed by just starting it from within the test directory. To prevent side effects with the running session it is recommended to start a dedicated dbus session:
cd path/to/build/directory/bin
dbus-run-session ./testFoo
For tests relying on X11 one should also either start a dedicated Xvfb and export DISPLAY or use xvfb-run as described above.