Package jscover.report

Examples of jscover.report.BranchData


        for (int j = 1; j < branchDatas.size(); j++) {
            Element conditionElement = doc.createElement("condition");
            conditionsElement.appendChild(conditionElement);
            conditionElement.setAttribute("number", "" + j);
            conditionElement.setAttribute("type", "jump");
            BranchData branchData = branchDatas.get(j);
            conditionElement.setAttribute("coverage", format("%d%%", branchData.getCoverage()));
            branches += 2;
            if (branchData.getEvalFalse() > 0)
                branchHits++;
            if (branchData.getEvalTrue() > 0)
                branchHits++;
        }
        lineElement.setAttribute("condition-coverage", format("%d%% (%d/%d)", Math.round(branchHits*100d/branches), branchHits, branches));
        return branchHits > 0;
    }
View Full Code Here


                "end_of_record\n";
        assertThat(result, equalTo(expected));
    }

    private BranchData getBranchData(int evalFalse, int evalTrue) {
        return new BranchData(0, 0, null, evalFalse, evalTrue);
    }
View Full Code Here

    public void shouldGenerateXmlBranchNoLine() throws Exception {
        List<Integer> lines = new ArrayList<Integer>();
        SortedMap<Integer, List<BranchData>> branchDataMap = new TreeMap<Integer, List<BranchData>>();
        List<BranchData> conditionsList = new ArrayList<BranchData>();
        conditionsList.add(null);
        conditionsList.add(new BranchData(0, 0, null, 1, 0));
        branchDataMap.put(1, conditionsList);
        files.add(new FileData("/dir/file.js", lines, null, branchDataMap));

        data = new CoberturaData(files);
        String xml = generator.generateXml(data, "srcDir", "version");
View Full Code Here

    public void shouldGenerateXmlLineAndBranch() throws Exception {
        List<Integer> lines = new ArrayList<Integer>(){{add(null);}{add(10);}};
        SortedMap<Integer, List<BranchData>> branchDataMap = new TreeMap<Integer, List<BranchData>>();
        List<BranchData> conditionsList = new ArrayList<BranchData>();
        conditionsList.add(null);
        conditionsList.add(new BranchData(0, 0, null, 0, 1));
        branchDataMap.put(1, conditionsList);
        files.add(new FileData("/dir/file.js", lines, null, branchDataMap));

        data = new CoberturaData(files);
        String xml = generator.generateXml(data, "srcDir", "version");
View Full Code Here

    public void shouldGenerateXmlBranchNoLineNoHit() throws Exception {
        List<Integer> lines = new ArrayList<Integer>();
        SortedMap<Integer, List<BranchData>> branchDataMap = new TreeMap<Integer, List<BranchData>>();
        List<BranchData> conditionsList = new ArrayList<BranchData>();
        conditionsList.add(null);
        conditionsList.add(new BranchData(0, 0, null, 0, 0));
        branchDataMap.put(1, conditionsList);
        files.add(new FileData("/dir/file.js", lines, null, branchDataMap));

        data = new CoberturaData(files);
        String xml = generator.generateXml(data, "srcDir", "version");
View Full Code Here

    private void processBranches(FileData coverageData, StringBuilder lcov) {
        for (Integer lineNumber: coverageData.getBranchData().keySet()) {
            List<BranchData> conditions = coverageData.getBranchData().get(lineNumber);
            if (conditions != null) {
                for (int j = 0; j < conditions.size(); j++) {
                    BranchData branch = conditions.get(j);
                    if (branch != null) {
                        //False path
                        String taken = branch.getEvalFalse() > 0 ? ""+branch.getEvalFalse() : "-";
                        lcov.append(format(branchData, lineNumber, j*2-1, taken));
                        //True path
                        taken = branch.getEvalTrue() > 0 ? ""+branch.getEvalTrue() : "-";
                        lcov.append(format(branchData, lineNumber, j*2, taken));
                    }
                }
            }
        }
View Full Code Here

TOP

Related Classes of jscover.report.BranchData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.