Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package coverage;
- import java.io.*;
- import org.junit.Test;
- import net.sourceforge.cobertura.coveragedata.*;
- public class CoverItAll
- {
- @Test
- public void coverItAll() throws Exception {
- File cdf = CoverageDataFileHandler.getDefaultDataFile();
- if (cdf.exists()) {
- ObjectInputStream ois = new ObjectInputStream(new FileInputStream(CoverageDataFileHandler.getDefaultDataFile()));
- ProjectData pd = (ProjectData) ois.readObject();
- ois.close();
- for(Object cd_ : pd.getClasses()) {
- ClassData cd = (ClassData) cd_;
- String name = cd.getName();
- for(CoverageData _line : cd.getLines()) {
- LineData line = (LineData) _line;
- int lino = line.getLineNumber();
- for (int i = 0; i < line.getConditionSize(); i++) {
- Object cond = line.getConditionData(i);
- if (cond instanceof JumpData) {
- JumpData jmp = (JumpData) cond;
- int jmpno = jmp.getConditionNumber();
- TouchCollector.touch(name, lino);
- TouchCollector.touchJump(name, lino, jmpno, false);
- TouchCollector.touch(name, lino);
- TouchCollector.touchJump(name, lino, jmpno, true);
- } else if (cond instanceof SwitchData) {
- SwitchData swi = (SwitchData) cond;
- int swino = swi.getSwitchNumber();
- TouchCollector.touch(name, lino);
- TouchCollector.touchSwitch(name, lino, swino, -1);
- for(int j=0; j<swi.getNumberOfValidBranches(); j++) {
- TouchCollector.touch(name, lino);
- TouchCollector.touchSwitch(name, lino, swino, j);
- }
- }
- }
- if (line.getConditionSize() == 0)
- TouchCollector.touch(name, lino);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement