Ignore some coverage depending on condition

24 views
Skip to first unread message

bald...@gmail.com

unread,
Aug 9, 2015, 2:00:21 PM8/9/15
to JaCoCo and EclEmma Users
Hello,

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.

Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages