Added testing documentation

pull/50/head
Jakub Matys 2018-08-18 15:53:33 +02:00
parent 8c5378eba2
commit 6f680ee8a3
2 changed files with 44 additions and 0 deletions

View File

@ -150,4 +150,8 @@ different approach for address representation than Bitcoin.
#### Add tests
Add unit tests and integration tests. Tests are described [here](/docs/testing.md).
#### Deploy public server
Deploy Blockbook server on public IP addres. Blockbook maintainers will check implementation before merging.

40
docs/testing.md 100644
View File

@ -0,0 +1,40 @@
# Testing
There are two kinds of tests in Blockbook unit tests and integration tests. Because integration tests require running
backend daemon so they can't be executed at every build. Blockbook's build system uses conditional compilation to
distinguish which tests should be executed.
To execute unit tests run `make test`. To execute unit tests and integration tests run `make test-all`. You can use
Go's flag *-run* to filter which tests should be executed. Use *ARGS* variable, e.g.
`make test-all ARGS="-run TestBitcoin"`.
## Unit tests
Unit test file must start with constraint `// +build unittest` followed by blank line (constraints are described
[here](https://golang.org/pkg/go/build/#hdr-Build_Constraints)).
Every coin implementation should have unit tests. At least for parser. Usual test suite define real transaction data
and try pack and unpack them. Specialites of particular coin are tested too. See examples in
[bcashparser_test.go](/bchain/coins/bch/bcashparser_test.go),
[bitcoinparser_test.go](/bchain/coins/btc/bitcoinparser_test.go) and
[ethparser_test.go](/bchain/coins/eth/ethparser_test.go).
## Integration tests
Integration test file must start with constraint `// +build integration` followed by blank line (constraints are
described [here](https://golang.org/pkg/go/build/#hdr-Build_Constraints)).
### Blockbook integration tests
TODO
### Back-end RPC integration tests
This kind of tests test *bchain.BlockChain* implementation and its capability to communicate with back-end RPC. Tests
of most of coins are similar so there is single generalized implementation in package *blockbook/bchain/tests/rpc*. Test
functions of particular coin implementation can just initialize test object and call its methods. Configuration of tests
is stored in *blockbook/bchain/tests/rpc/config.json* and consists of back-end URL and credentials. Every test suite also
has fixtures stored in *blockbook/bchain/tests/rpc/testdata*. Content is obvious from existing files.
For example see [bitcoinrpc_test.go](/bchain/coins/btc/bitcoinrpc_test.go).