In the meanwhile I managed to solve my original problem in another way, so I don’t need to check for the existence of tests anymore.
Thanks for having at look at it, Ben. The behavior seems a bit strange at first as I
didn’t expect multiple tests with the same name to be valid and
did expect that if(TEST ...) works globally or at least catches the same tests as ctest would do on a directory level (tests defined in the current level and below)
Perhaps the documentation could be improved at that point.
However for me its solved, as I don’t need it anymore.