<p>You are confusing the two kinds of tests. Unit tests are compiled into a separate binary and run by <code>make check</code>. Functional tests are testing the RPC commands and have to be run explicitly using the <code>test_runner.py</code> script. <code>test_framework.log</code> is only created by the functional tests. The documentation for the unit tests can be found <a href="https://github.com/bitcoin/bitcoin/blob/master/src/test/README.md" rel="nofollow noreferrer">here</a>.</p>

<p>To print messages in the unit tests, you cannot use <code>LogPrintf</code>. Instead use <code>BOOST_TEST_MESSAGE</code> and <code>BOOST_CHECK_MESSAGE</code> to print messages from the tests. You will have to run the test binary directly (<code>src/test/test_bitcoin</code>) with <code>--log_level=all</code> to see the messages.</p>

<p>To print from the source files themselves, you could use <code>fprintf()</code> and print your messages to stderr.</p>

CC BY-SA 4.0
2018-06-25T13:33:32.700Z
Ok, that makes more sense, I think this will allow printing messages from the test files, but what about the source files?  Eg. `net_processing.cpp`
JBaczuk
CC BY-SA 4.0
2018-06-25T20:40:34.380Z
You can use `fprintf`. Updated the answer
Ava Chow
CC BY-SA 4.0
2020-09-10T15:38:12.730Z
nit: The test_runner.py script allows you to run all functional tests in parallel but you don't *have* to use it.
Michael Folkson
CC BY-SA 4.0
2018-06-25T07:36:37.470Z
2018-06-25T20:40:20.737Z
2018-06-25T20:40:20.737Z
Ava Chow
<p>I am running the unit tests from bitcoin source using <code>make check</code>, and would like to debug the tests using <code>LogPrint</code> in the bitcoin source files. I read in the <a href="https://github.com/bitcoin/bitcoin/tree/master/test" rel="nofollow noreferrer">Test Docs</a> that logs are only output to <code>test_framework.log</code>, but I'm unable to locate this file. Where should I be able to find it? Or perhaps there is a better approach?</p>

<bitcoin-core-development><debugging><unit-test>
Debugging Bitcoin Unit Tests
JBaczuk
# Debugging Bitcoin Unit Tests

(Asked by: username_0 on 2018-06-22)

I am running the unit tests from bitcoin source using `make check`, and would like to debug the tests using `LogPrint` in the bitcoin source files. I read in the [Test Docs](https://github.com/bitcoin/bitcoin/tree/master/test) that logs are only output to `test_framework.log`, but I'm unable to locate this file. Where should I be able to find it? Or perhaps there is a better approach?

**Tags:** bitcoin-core-development, debugging, unit-test


---

## 1 answers

### Answer by username_1 on 2018-06-25. Score: 3 | Accepted answer

You are confusing the two kinds of tests. Unit tests are compiled into a separate binary and run by `make check`. Functional tests are testing the RPC commands and have to be run explicitly using the `test_runner.py` script. `test_framework.log` is only created by the functional tests. The documentation for the unit tests can be found [here](https://github.com/bitcoin/bitcoin/blob/master/src/test/README.md).

To print messages in the unit tests, you cannot use `LogPrintf`. Instead use `BOOST_TEST_MESSAGE` and `BOOST_CHECK_MESSAGE` to print messages from the tests. You will have to run the test binary directly (`src/test/test_bitcoin`) with `--log_level=all` to see the messages.

To print from the source files themselves, you could use `fprintf()` and print your messages to stderr.

> **Comments:**
> **username_0**: Ok, that makes more sense, I think this will allow printing messages from the test files, but what about the source files?  Eg. `net_processing.cpp`  
> **username_1**: You can use `fprintf`. Updated the answer  
> **username_2**: nit: The test_runner.py script allows you to run all functional tests in parallel but you don't *have* to use it.  

---

