<p>If your intention is to contribute to Bitcoin Core, you must be able to build these reports locally. So that you can compare if your changes have been effective at increasing coverage.</p>
<p>The general steps are:</p>
<ul>
<li><a href="https://github.com/bitcoin/bitcoin/tree/master/doc#building" rel="nofollow noreferrer">Download the code and compile it</a></li>
<li>Install LCOV for report generation</li>
<li>Configure bitcoin to enable line coverage, ie <code>--enable-lcov</code></li>
<li>Execute the coverage task, ie <code>make cov</code></li>
</ul>
<p>Once you have the dev environment correctly setup, the commands are:</p>
<pre><code>./configure --enable-lcov
make cov
</code></pre>
<p>The official docs are located here: <a href="https://github.com/bitcoin/bitcoin/blob/8d6f9210d90b350a9248f853ed8c559ef5e12505/doc/developer-notes.md#compiling-for-test-coverage" rel="nofollow noreferrer">developer-notes.md#compiling-for-test-coverage</a></p>

CC BY-SA 4.0
2022-02-27T02:31:26.440Z
Here's a guide I wrote: https://givan.se/generate-bitcoin-line-coverage-reports
givanse
CC BY-SA 4.0
2022-02-27T02:30:07.097Z
2022-02-27T02:30:07.097Z
givanse
<p>Marco Falke has a <a href="https://maflcko.github.io/b-c-cov/" rel="nofollow noreferrer">site</a> that analyzes the current line, function and branch coverage for unit tests, functional tests and fuzz tests.</p>
<p>Alternatively, vasild runs clang's tools and then a <a href="https://github.com/vasild/filter_coverage" rel="nofollow noreferrer">script</a> to highlight which lines in the coverage report have been modified by a particular patch (PR).</p>

CC BY-SA 4.0
2023-07-14T11:22:25.813Z
The link to MarcoFalke's website is dead, https://marcofalke.github.io/b-c-cov/ seems to be the new one.
stickies-v
CC BY-SA 4.0
2023-07-17T10:14:03.810Z
@stickies-v: Thanks, updated.
Michael Folkson
CC BY-SA 4.0
2020-09-25T23:08:46.017Z
2024-12-08T12:40:28.080Z
2024-12-08T12:40:28.080Z
Michael Folkson
<p>I have heard <a href="https://bitcoin.stackexchange.com/questions/90389/is-writing-unit-tests-a-good-way-to-start-contributing-to-bitcoin-core">writing tests</a> is a good starting point for contributing to Bitcoin Core. How do I work out which parts or specific lines of the codebase need additional test coverage?</p>

<bitcoin-core-development><testing><functional-test><unit-test>
How can I analyze the test coverage of the Bitcoin Core codebase?
Michael Folkson
# How can I analyze the test coverage of the Bitcoin Core codebase?

(Asked by: username_0 on 2020-09-25)

I have heard [writing tests](https://bitcoin.stackexchange.com/questions/90389/is-writing-unit-tests-a-good-way-to-start-contributing-to-bitcoin-core) is a good starting point for contributing to Bitcoin Core. How do I work out which parts or specific lines of the codebase need additional test coverage?

**Tags:** bitcoin-core-development, testing, functional-test, unit-test


---

## 2 answers

### Answer by username_0 on 2020-09-25. Score: 6 | Accepted answer

Marco Falke has a [site](https://maflcko.github.io/b-c-cov/) that analyzes the current line, function and branch coverage for unit tests, functional tests and fuzz tests.

Alternatively, vasild runs clang's tools and then a [script](https://github.com/vasild/filter_coverage) to highlight which lines in the coverage report have been modified by a particular patch (PR).

> **Comments:**
> **username_2**: The link to MarcoFalke's website is dead, https://marcofalke.github.io/b-c-cov/ seems to be the new one.  
> **username_0**: @username_2: Thanks, updated.  

---

### Answer by username_1 on 2022-02-27. Score: 4

If your intention is to contribute to Bitcoin Core, you must be able to build these reports locally. So that you can compare if your changes have been effective at increasing coverage.
The general steps are:

Download the code and compile it
Install LCOV for report generation
Configure bitcoin to enable line coverage, ie --enable-lcov
Execute the coverage task, ie make cov

Once you have the dev environment correctly setup, the commands are:
./configure --enable-lcov
make cov

The official docs are located here: developer-notes.md#compiling-for-test-coverage

> **Comments:**
> **username_1**: Here's a guide I wrote: https://givan.se/generate-bitcoin-line-coverage-reports  

---

