I have tests that can be run only on certain operation system (namely Windows and Linux). They test that some file operation - specific to each system - works:
For Windows:
@Override
protected DosFileAttributes mapAttributes(BasicFileAttributes attr) {
if (attr instanceof DosFileAttributes) {
return (DosFileAttributes) attr;
}
return null;
}
For Linux:
@Override
protected BasicFileAttributes mapAttributes(BasicFileAttributes attr) {
return attr;
}
The code coverage will be obviously 0% when run on Windows or Linux.
I'd like to know if there was some annotations already existing that could avoid this case:
@Coverage(ignoreWhenOperationSystemIsNot = {WINDOWS})
@Override
protected DosFileAttributes mapAttributes(BasicFileAttributes attr) {
if (attr instanceof DosFileAttributes) {
return (DosFileAttributes) attr;
}
return null;
}
@Coverage(ignoreWhenOperationSystemIsNot = {LINUX})
@Override
protected BasicFileAttributes mapAttributes(BasicFileAttributes attr) {
return attr;
}
The @Coverage annotation would work like this: ignore the class or method in coverage result only if OS does not match expected.