Package hudson.plugins.cobertura.targets

Examples of hudson.plugins.cobertura.targets.CoverageResult


  @SuppressWarnings("unchecked")
  @Test
  public void fullRange() throws IOException
  {
    ctl = EasyMock.createControl();
    CoverageResult result = new CoverageResultBuilder( ctl )//
        .result( 0 )//
        .result( 0 )//
        .result( 1000 )//
        .result( 1000 ).create();
    CoverageChart chartData = new CoverageChart( result, true, 0 );
View Full Code Here


  @SuppressWarnings("unchecked")
  @Test
  public void closeup() throws IOException
  {
    ctl = EasyMock.createControl();
    CoverageResult result = new CoverageResultBuilder( ctl )//
        .result( 105 )//
        .result( 115 )//
        .result( 108 )//
        .result( 111, 108, 107, 114, 113, 109 ).create();
    CoverageChart chartData = new CoverageChart( result, true, 0 );
View Full Code Here

  @SuppressWarnings("unchecked")
  @Test
  public void nozoom() throws IOException
  {
    ctl = EasyMock.createControl();
    CoverageResult result = new CoverageResultBuilder( ctl )//
        .result( 105 )//
        .result( 115 )//
        .result( 108 )//
        .result( 111, 108, 107, 114, 113, 109 ).create();
    CoverageChart chartData = new CoverageChart( result, false, 0 );
View Full Code Here

     * @param fileName the name of the resource to parse
     * @return a CoverageResult object
     */
    private CoverageResult loadResults(String fileName) throws Exception {
        InputStream in = getClass().getResourceAsStream(fileName);
        CoverageResult result = CoberturaCoverageParser.parse(in, null);
        return result;
    }
View Full Code Here

    /**
     * Tests the behavior of {@link CoverageResult#setOwner(AbstractBuild)}.
     */
    public void testSetOwner() throws Exception {
        ctl.replay();
        CoverageResult result = loadResults(FILE_COVERAGE_DATA);
        assertNull(result.getOwner());
        result.setOwner(build);
        assertSame(build, result.getOwner());
        ctl.verify();
    }
View Full Code Here

    /**
     * Tests the behavior of {@link CoverageResult#getResults()}.
     */
    public void testGetResults() throws Exception {
        ctl.replay();
        CoverageResult result = loadResults(FILE_COVERAGE_DATA);
        assertEquals(Collections.EMPTY_MAP, result.getResults());
        result.setOwner(build);
        Map<CoverageMetric,Ratio> metrics = result.getResults();
        assertEquals(6, result.getResults().size());
        assertEquals(Ratio.create(2, 2), metrics.get(CoverageMetric.PACKAGES));
        assertEquals(Ratio.create(3, 3), metrics.get(CoverageMetric.FILES));
        assertEquals(Ratio.create(3, 3), metrics.get(CoverageMetric.CLASSES));
        assertEquals(Ratio.create(7, 7), metrics.get(CoverageMetric.METHOD));
        assertEquals(Ratio.create(27, 30), metrics.get(CoverageMetric.LINE));
View Full Code Here

    /**
     * Test behavior of {@link CoverageResult#getMetricsWithEmpty()}.
     */
    public void testGetMetricsWithEmpty() throws Exception {
      ctl.replay();
      CoverageResult result = loadResults("coverage-no-data.xml");
      Set<CoverageMetric> metrics = result.getMetricsWithEmpty();
      List<CoverageMetric> allMetrics = new LinkedList<CoverageMetric>(Arrays.asList(CoverageMetric.PACKAGES, CoverageMetric.FILES, CoverageMetric.CLASSES, CoverageMetric.METHOD, CoverageMetric.LINE, CoverageMetric.CONDITIONAL));
      assertEquals(metrics.size(), allMetrics.size());
      ctl.verify();
    }
View Full Code Here

     * Tests the behavior of {@link CoverageResult#getParent()}.
     */
    public void testGetParent() throws Exception {
        ctl.replay();
        // Project level
        CoverageResult result = loadResults(FILE_COVERAGE_DATA);
        result.setOwner(build);
        assertNull(result.getParent());
        // Package level
        CoverageResult expectedParent = result;
        result = result.getChild("search");
        assertSame(expectedParent, result.getParent());
        // File level
        expectedParent = result;
        result = result.getChild("LinearSearch.java");
View Full Code Here

     */
    public void testGetParents() throws Exception {
        ctl.replay();
        // Project level
        LinkedList<CoverageResult> expectedParents = new LinkedList<CoverageResult>();
        CoverageResult result = loadResults(FILE_COVERAGE_DATA);
        result.setOwner(build);
        assertEquals(expectedParents, result.getParents());
        // Package level
        expectedParents.add(result);
        result = result.getChild("search");
        assertEquals(expectedParents, result.getParents());
        // File level
        expectedParents.add(result);
        result = result.getChild("LinearSearch.java");
        assertEquals(expectedParents, result.getParents());
        // Class level
        expectedParents.add(result);
        result = result.getChild("LinearSearch");
        assertEquals(expectedParents, result.getParents());
        // Method level
        expectedParents.add(result);
        result = result.getChild("int find(int,int)");
        assertEquals(expectedParents, result.getParents());
        ctl.verify();
    }
View Full Code Here

     * Tests the behavior of {@link CoverageResult#getChildElements()}.
     */
    public void testGetChildElements() throws Exception {
        ctl.replay();
        // Project level
        CoverageResult result = loadResults(FILE_COVERAGE_DATA);
        result.setOwner(build);
        assertEquals(Collections.singleton(CoverageElement.JAVA_PACKAGE), result.getChildElements());
        // Package level
        result = result.getChild("search");
        assertEquals(Collections.singleton(CoverageElement.JAVA_FILE), result.getChildElements());
        // File level
        result = result.getChild("LinearSearch.java");
        assertEquals(Collections.singleton(CoverageElement.JAVA_CLASS), result.getChildElements());
        // Class level
        result = result.getChild("LinearSearch");
        assertEquals(Collections.singleton(CoverageElement.JAVA_METHOD), result.getChildElements());
        // Method level
        result = result.getChild("int find(int,int)");
        assertEquals(Collections.emptySet(), result.getChildElements());
        ctl.verify();
    }
View Full Code Here

TOP

Related Classes of hudson.plugins.cobertura.targets.CoverageResult

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.