Merge lp:~allanlesage/coverage-builder/test-fifty-percent-coverage into lp:coverage-builder

Proposed by Allan LeSage
Status: Merged
Merged at revision: 275
Proposed branch: lp:~allanlesage/coverage-builder/test-fifty-percent-coverage
Merge into: lp:coverage-builder
Prerequisite: lp:~allanlesage/coverage-builder/build-test
Diff against target: 38 lines (+24/-0)
1 file modified
test/test_test.py (+24/-0)
To merge this branch: bzr merge lp:~allanlesage/coverage-builder/test-fifty-percent-coverage
Reviewer Review Type Date Requested Status
Martin Pitt (community) Needs Fixing
Review via email: mp+234754@code.launchpad.net

Description of the change

Quickie test for 50% coverage.

Martin you earlier suggested marking up the code with tags to extract--is just substituting the file adequate?

To post a comment you must log in.
Revision history for this message
Martin Pitt (pitti) wrote :

Sure, replacing the entire file works too. I just meant that replacing a macro comment might be easier than always rewriting entire files for some tests.

The assertion needs to be fixed, otherwise LGTM. (Please just merge after fixing)

review: Needs Fixing
281. By Allan LeSage

Correct float assertion in incomplete coverage test.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'test/test_test.py'
2--- test/test_test.py 2014-09-16 16:30:42 +0000
3+++ test/test_test.py 2014-09-16 16:30:42 +0000
4@@ -4,6 +4,7 @@
5 # Author: Allan LeSage <allan.lesage@canonical.com>
6 # License: GPL 3 or later
7
8+import os
9 import xml.etree.ElementTree as etree
10
11 from test import CoverageBuilderTestCase, snip_coverage_xml
12@@ -28,3 +29,26 @@
13 root = etree.fromstring(coverage_xml)
14 node = root.find(".//*[@filename='fibonacci.cpp']")
15 self.assertEqual(1.0, float(node.attrib['line-rate']))
16+
17+ def test_fifty_percent_coverage(self):
18+ """Accurate line coverage for a less thorough test suite."""
19+ test_fibonacci_cpp_contents = """
20+#include "gtest/gtest.h"
21+#include "fibonacci.h"
22+
23+TEST(FibonacciTest, FirstTermIsCorrect) {
24+ EXPECT_EQ(0, fib(0));
25+}
26+"""
27+ with open(os.path.join(self.pkgdir,
28+ 'tests',
29+ 'test_fibonacci.cpp'),
30+ 'w') as test_fibonacci_cpp:
31+ test_fibonacci_cpp.write(test_fibonacci_cpp_contents)
32+ self._call_dh_auto_configure()
33+ self._call_dh_auto_build()
34+ out, err = self._call_dh_auto_test()
35+ coverage_xml = snip_coverage_xml(out.decode())
36+ root = etree.fromstring(coverage_xml)
37+ node = root.find(".//*[@filename='fibonacci.cpp']")
38+ self.assertAlmostEqual(0.5, float(node.attrib['line-rate']))

Subscribers

People subscribed via source and target branches