Skip to content

Commit

Permalink
feat: poetry script for easier test case running (#445)
Browse files Browse the repository at this point in the history
* Add poetry run test shortcut scripts

* Add test coverage scripts
  • Loading branch information
connorjchen committed Oct 3, 2022
1 parent ba24b71 commit 96697c1
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/integration_test.yml
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
4 changes: 2 additions & 2 deletions .github/workflows/unit_test.yml
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
Expand Up @@ -68,10 +68,18 @@ poetry run flake8 ./xrpl

### Running Tests

#### Individual Tests

```bash
# Works for single or multiple unit/integration tests
# Ex: poetry run poe test tests/unit/models/test_response.py tests/integration/transactions/test_account_delete.py
poetry run poe test FILE_PATHS
```

#### Unit Tests

```bash
poetry run python3 -m unittest discover tests/unit
poetry run poe test_unit
```

#### 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
poetry run poe test_integration
```

#### Code Coverage

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

To see manually code coverage after running unit tests or integration tests:
```bash
poetry run coverage report
```

#### 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
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
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}]

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

0 comments on commit 96697c1

Please sign in to comment.