Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Cannot Reproduce
-
Affects Version/s: 2.13.1
-
Fix Version/s: None
-
Component/s: Code Coverage
-
Labels:
-
Environment:Sonar v.2.13.1 configured with JaCoCo
-
Number of attachments :
Description
Sonar shows half code coverage for single statement methods. As these lines are without if or ternary operator I don't think it could be half covered anyway.
The Eclipse EclEmma plugin (EclEmma Java Code Coverage version 2.1.0.201202261248) shows full coverage.
Sonar v.2.13.1 configured with JaCoCo
DefaultEventLogService.java
@Service("defaultEventLogService ") public class DefaultEventLogService implements EventLogService { @Autowired private EventLogRepository eventLogRepository; @Transactional public void createEventLog(EventLog eventLog) { eventLogRepository.createEventLog(eventLog); } }
DefaultEventLogServiceTest.java
@RunWith(MockitoJUnitRunner.class) public class DefaultEventLogServiceTest { @InjectMocks private final EventLogService victim = new DefaultEventLogService(); @Mock private EventLogRepository eventLogRepository; @Mock private EventLog eventLog; @Test public void createEventLog() { victim.createEventLog(eventLog); verify(eventLogRepository).createEventLog(eventLog); } }
Even if the test is without MockitoJUnitRunner, with setUp() and ReflectionTestUtils, Sonar shows half coverage.
Activity
Ferenc Gratzer
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Attachment | Sonar-half-coverage.jpg [ 59422 ] |
Ferenc Gratzer
made changes -
| Attachment | Sonar-half-coverage.jpg [ 59423 ] |
Freddy Mallet
made changes -
| Labels | jacoco |
Freddy Mallet
made changes -
| Assignee | Freddy Mallet [ freddy.mallet ] |
Ferenc Gratzer
made changes -
| Attachment | eclemma-coverage.jpg [ 59424 ] |
Ferenc Gratzer
made changes -
| Attachment | Sonar-half-coverage2.jpg [ 59426 ] | |
| Attachment | Sonar-half-coverage3.jpg [ 59427 ] |
Ferenc Gratzer
made changes -
| Attachment | DefaultEventLogService.class.txt [ 59428 ] |
Freddy Mallet
made changes -
| Assignee | Freddy Mallet [ freddy.mallet ] |
Freddy Mallet
made changes -
| Status | Open [ 1 ] | Closed [ 6 ] |
| Resolution | Cannot Reproduce [ 5 ] |
Sonar half coverage for single statement