@matheusbsbs / matheus-bagliano / commits / 0c357544b0
Fork 0

t/README: A new section about test coverage

Document how test writers can generate coverage reports, to ensure that their tests are really testing the code they think they're testing. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Jul 25, 2010 at 19:52 UTC 0c357544b0d4415c464fb8b35593b21db1d1f7f7
1 file changed +42
t/README
+42
@@ -268,6 +268,9 @@ Do:
268 git push gh &&
269 test ...
270
271 + - Check the test coverage for your tests. See the "Test coverage"
272 + below.
273 +
274 Don't:
275
276 - exit() within a <script> part.
@@ -555,6 +558,45 @@ validation in one place. Your test also ends up needing
558 updating when such a change to the internal happens, so do _not_
559 do it and leave the low level of validation to t0000-basic.sh.
560
561 +Test coverage
562 +-------------
563 +
564 +You can use the coverage tests to find code paths that are not being
565 +used or properly exercised yet.
566 +
567 +To do that, run the coverage target at the top-level (not in the t/
568 +directory):
569 +
570 + make coverage
571 +
572 +That'll compile Git with GCC's coverage arguments, and generate a test
573 +report with gcov after the tests finish. Running the coverage tests
574 +can take a while, since running the tests in parallel is incompatible
575 +with GCC's coverage mode.
576 +
577 +After the tests have run you can generate a list of untested
578 +functions:
579 +
580 + make coverage-untested-functions
581 +
582 +You can also generate a detailed per-file HTML report using the
583 +Devel::Cover module. To install it do:
584 +
585 + # On Debian or Ubuntu:
586 + sudo aptitude install libdevel-cover-perl
587 +
588 + # From the CPAN with cpanminus
589 + curl -L http://cpanmin.us | perl - --sudo --self-upgrade
590 + cpanm --sudo Devel::Cover
591 +
592 +Then, at the top-level:
593 +
594 + make cover_db_html
595 +
596 +That'll generate a detailed cover report in the "cover_db_html"
597 +directory, which you can then copy to a webserver, or inspect locally
598 +in a browser.
599 +
600 Smoke testing
601 -------------
602