In tests for code failure due to non-compilation, it makes little sense to use unit testing, even if you could.
The ability to unit test the code section does not compile, does not have its own value, since the code cannot be used in any case.
You may have an automated build process that runs unit tests after the test code is built without errors, but the fact that the compiler throws an error is a failure in itself.
To check the correctness of the code, module testers are used.
source share