Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: poetry script for easier test case running #445

Merged
merged 12 commits into from
Oct 3, 2022
4 changes: 2 additions & 2 deletions .github/workflows/integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ jobs:

- name: Integration test
run: |
poetry run coverage run -m unittest discover tests.integration
poetry run coverage report -m --fail-under=70
poetry run poe test_integration
poetry run coverage report --fail-under=70
mvadari marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions .github/workflows/unit_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,5 @@ jobs:

- name: Unit test
run: |
poetry run coverage run -m unittest discover tests.unit
poetry run coverage report -m --fail-under=85
poetry run poe test_unit
poetry run coverage report --fail-under=85
24 changes: 22 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,18 @@ poetry run flake8 ./xrpl

### Running Tests

#### Individual Tests

```bash
# Works for single or multiple unit/integration tests
# Ex: poe test tests/unit/clients/test_json_rpc_client.py tests/integration/transactions/test_account_delete.py
poe test FILE_PATHS
```

#### Unit Tests

```bash
poetry run python3 -m unittest discover tests/unit
poe test_unit
connorjchen marked this conversation as resolved.
Show resolved Hide resolved
```

#### Integration Tests
Expand All @@ -84,7 +92,19 @@ docker run -p 5005:5005 -p 6006:6006 -it natenichols/rippled-standalone:latest
To actually run the tests:

```bash
poetry run python3 -m unittest discover tests/integration
poe test_integration
```

#### Code Coverage

To see manually code coverage after running unit tests or integration tests:
```bash
coverage report -m
```

To run both unit and integration tests and see code coverage:
```bash
poe test_coverage
```

#### Running tests with different Python versions
Expand Down
25 changes: 25 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ coverage = "^6.4.1"
Jinja2 = "^2.11.3"
MarkupSafe = "2.0.1"
Sphinx = "^5.1.1"
poethepoet = "^0.16.2"

[tool.isort]
# Make sure that isort's settings line up with black
Expand All @@ -71,3 +72,20 @@ build-backend = "poetry.core.masonry.api"
[tool.coverage.run]
branch = true
source = ["xrpl"]

[tool.coverage.report]
show_missing = true
connorjchen marked this conversation as resolved.
Show resolved Hide resolved
skip_covered = true
skip_empty = true
precision = 2

[tool.poe.tasks]
test_unit = "coverage run -m unittest discover tests/unit"
test_integration = "coverage run -m unittest discover tests/integration"

[tool.poe.tasks.test]
cmd = "python3 -m unittest ${FILE_PATHS}"
args = [{ name = "FILE_PATHS", positional = true, multiple = true}]
connorjchen marked this conversation as resolved.
Show resolved Hide resolved

[tool.poe.tasks.test_coverage]
sequence = [{ cmd = "coverage run -m unittest discover" }, { cmd = "coverage report --fail-under=90" }]