mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Problem: tests/README.md either wrong or redundant (#2479)
The information on that page was either wrong or redundant, so I either deleted it or linked to where to find the same information in the docs about contributing to BigchainDB.
This commit is contained in:
parent
f8bb29535a
commit
c72c7a4626
104
tests/README.md
104
tests/README.md
@ -4,103 +4,13 @@ SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
||||
Code is Apache-2.0 and docs are CC-BY-4.0
|
||||
--->
|
||||
|
||||
# BigchainDB Server Tests
|
||||
# BigchainDB Server Unit Tests
|
||||
|
||||
## The tests/ Folder
|
||||
Most of the tests in the `tests/` folder are unit tests. For info about how to write and run tests, see [the docs about contributing to BigchainDB](http://docs.bigchaindb.com/projects/contributing/en/latest/index.html), especially:
|
||||
|
||||
The `tests/` folder is where all the tests for BigchainDB Server live. Most of them are unit tests. Integration tests are in the [`tests/integration/` folder](./integration/).
|
||||
- [Write Code - Remember to Write Tests](http://docs.bigchaindb.com/projects/contributing/en/latest/dev-setup-coding-and-contribution-process/write-code.html#remember-to-write-tests)
|
||||
- [Notes on Running a Local Dev Node with Docker Compose](http://docs.bigchaindb.com/projects/contributing/en/latest/dev-setup-coding-and-contribution-process/run-node-with-docker-compose.html), especially `make test`
|
||||
- [
|
||||
Notes on Running a Local Dev Node as Processes (and Running All Tests)](http://docs.bigchaindb.com/projects/contributing/en/latest/dev-setup-coding-and-contribution-process/run-node-as-processes.html)
|
||||
|
||||
A few notes:
|
||||
|
||||
- [`tests/common/`](./common/) contains self-contained tests only testing
|
||||
[`bigchaindb/common/`](../bigchaindb/common/)
|
||||
- [`tests/backend/`](./backend/) contains tests requiring
|
||||
the database backend (MongoDB)
|
||||
|
||||
|
||||
## Writing Tests
|
||||
|
||||
We write unit and integration tests for our Python code using the [pytest](http://pytest.org/latest/) framework. You can use the tests in the `tests/` folder as templates or examples.
|
||||
|
||||
|
||||
## Running Tests
|
||||
|
||||
### Running Tests Directly
|
||||
|
||||
If you installed BigchainDB Server using `pip install bigchaindb`, then you
|
||||
didn't install the tests. Before you can run all the tests, you must install
|
||||
BigchainDB from source. The [`CONTRIBUTING.md` file](../CONTRIBUTING.md) has
|
||||
instructions for how to do that.
|
||||
|
||||
Next, make sure you have Local MongoDB running in the background. You
|
||||
can run MongoDB using `mongod`.
|
||||
|
||||
The `pytest` command has many options. If you want to learn about all the
|
||||
things you can do with pytest, see [the pytest
|
||||
documentation](http://pytest.org/latest/). We've also added a customization to
|
||||
pytest:
|
||||
|
||||
`--database-backend`: Defines the backend to use for the tests. It defaults to
|
||||
`localmongodb`.
|
||||
|
||||
Now you can run all tests using:
|
||||
```text
|
||||
pytest -v
|
||||
```
|
||||
|
||||
or, if that doesn't work, try:
|
||||
```text
|
||||
python -m pytest -v
|
||||
```
|
||||
|
||||
or:
|
||||
```text
|
||||
python setup.py test
|
||||
```
|
||||
|
||||
How does `python setup.py test` work? The documentation for [pytest-runner](https://pypi.python.org/pypi/pytest-runner) explains.
|
||||
|
||||
The `pytest` command has many options. If you want to learn about all the things you can do with pytest, see [the pytest documentation](http://pytest.org/latest/). We've also added a customization to pytest:
|
||||
|
||||
|
||||
### Running Tests with Docker Compose
|
||||
|
||||
You can also use [Docker Compose](https://docs.docker.com/compose/) to run all the tests.
|
||||
|
||||
First, bring up all the services BigchainDB, MongoDB, Tendermint in the background:
|
||||
|
||||
```text
|
||||
$ docker-compose up -d bdb
|
||||
```
|
||||
|
||||
then run the tests using:
|
||||
|
||||
```text
|
||||
$ docker-compose run --rm --no-deps bigchaindb pytest -v
|
||||
```
|
||||
|
||||
## Automated Testing of All Pull Requests
|
||||
|
||||
We use [Travis CI](https://travis-ci.com/), so that whenever someone creates a new BigchainDB pull request on GitHub, Travis CI gets the new code and does _a bunch of stuff_. We use the same `docker-compose.yml` for tests. It tells Travis CI how to install BigchainDB, how to run all the tests, and what to do "after success" (e.g. run `codecov`). (We use [Codecov](https://codecov.io/) to get a rough estimate of our test coverage.)
|
||||
|
||||
|
||||
### Tox
|
||||
|
||||
We use [tox](https://tox.readthedocs.io/en/latest/) to run multiple suites of tests against multiple environments during automated testing. Generally you don't need to run this yourself, but it might be useful when troubleshooting a failing Travis CI build.
|
||||
|
||||
To run all the tox tests, use:
|
||||
```text
|
||||
tox
|
||||
```
|
||||
|
||||
or:
|
||||
```text
|
||||
python -m tox
|
||||
```
|
||||
|
||||
To run only a few environments, use the `-e` flag:
|
||||
```text
|
||||
tox -e {ENVLIST}
|
||||
```
|
||||
|
||||
where `{ENVLIST}` is one or more of the environments specified in the [tox.ini file](../tox.ini).
|
||||
Note: There are acceptance tests in the `acceptance/` folder (at the same level in the hierarchy as the `tests/` folder).
|
||||
|
Loading…
x
Reference in New Issue
Block a user