Beispiel #1
0
    def test_empty_cobertura_file(self):
        jobstep = JobStep(
            id=uuid.uuid4(),
            job=Job(id=uuid.uuid4(), project_id=uuid.uuid4())
        )

        fp = StringIO('')

        handler = CoverageHandler(jobstep)
        results = handler.get_coverage(fp)

        # most importantly, it shouldn't crash
        assert len(results) == 0
Beispiel #2
0
    def test_jacoco_result_generation(self):
        jobstep = JobStep(
            id=uuid.uuid4(),
            job=Job(id=uuid.uuid4(), project_id=uuid.uuid4())
        )

        handler = CoverageHandler(jobstep)
        with open(os.path.join(os.path.dirname(__file__), 'fixtures', 'jacoco-coverage.xml')) as fp:
            results = handler.get_coverage(fp)

        assert len(results) == 1

        r1 = results[0]
        assert type(r1) == FileCoverage
        assert r1.job_id == jobstep.job.id
        assert r1.project_id == jobstep.job.project_id
        assert r1.filename == 'src/main/java/com/dropbox/apx/onyx/api/resource/stats/StatsResource.java'
        assert r1.data == 'NNNNCCCCNNCCUU'
Beispiel #3
0
    def test_cobertura_result_generation(self):
        jobstep = JobStep(
            id=uuid.uuid4(),
            job=Job(id=uuid.uuid4(), project_id=uuid.uuid4())
        )

        fp = StringIO(SAMPLE_COVERAGE)

        handler = CoverageHandler(jobstep)
        results = handler.get_coverage(fp)

        assert len(results) == 2

        r1 = results[0]
        assert type(r1) == FileCoverage
        assert r1.job_id == jobstep.job.id
        assert r1.project_id == jobstep.job.project_id
        assert r1.filename == 'setup.py'
        assert r1.data == 'NUNNNNNNNNNUCCNU'
        r2 = results[1]
        assert type(r2) == FileCoverage
        assert r2.job_id == jobstep.job.id
        assert r2.project_id == jobstep.job.project_id
        assert r2.data == 'CUCNNNU'  # partial branch coverage is considered uncovered