I think there is a missing step here:
https://github.com/PX4/Devguide/blob/6194b65f72615ffbcb4c8ed07a6b2a07a9a9362d/en/test_and_ci/unit_tests.md
In the section Writing a SITL Unit Test, we also need to add the test to platforms/posix/cmake/sitl_tests.cmake, and it's not mentioned anywhere.