JCov seems to ignore calls made from inner classes of test that were triggered by call of JDK.
For example the following approach for calling the tested method JInternalFrame::paintComponent(Graphics) leads to JCov not recording the coverage
Say, we have a custom JInternalFrame that has paintComponent() method overridden to record the call and call super.paintComponent(g).
public void myTest() {
JInternalFrame jInternalFrame = new JInternalFrame("Internal frame") {
@Override
public void paintComponent(Graphics g) {
methodCalled.set(true);
super.paintComponent(g);
}
};
// showing frame to have paintComponent called
}
Method paintComponent() is called by Swing machinery when showing component, not directly by the test (and that's the idea of testing)
however in the overridden version of the method super.paintComponent(g) is called explicitly after the call is recorded by the test.
Yet this explicit call to super method is not recorded by JCov
For example the following approach for calling the tested method JInternalFrame::paintComponent(Graphics) leads to JCov not recording the coverage
Say, we have a custom JInternalFrame that has paintComponent() method overridden to record the call and call super.paintComponent(g).
public void myTest() {
JInternalFrame jInternalFrame = new JInternalFrame("Internal frame") {
@Override
public void paintComponent(Graphics g) {
methodCalled.set(true);
super.paintComponent(g);
}
};
// showing frame to have paintComponent called
}
Method paintComponent() is called by Swing machinery when showing component, not directly by the test (and that's the idea of testing)
however in the overridden version of the method super.paintComponent(g) is called explicitly after the call is recorded by the test.
Yet this explicit call to super method is not recorded by JCov