diff --git a/README.md b/README.md index e586751..2a90096 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,12 @@ This is an example repository with tests in the `tests/examples/` directory. To run the tests : +### Compatibility + +As of this release, Python 3.7 and 3.8 are no longer supported. +The supported Python versions are: +3.9, 3.10, 3.11, 3.12, and 3.13. + 1. Clone the repository with `git clone https://github.com/cskmnrpt/qase-pytest.git`. To clone a different branch, other than `main`, use this command -
`git clone --single-branch --branch https://github.com/cskmnrpt/qase-pytest.git` @@ -21,3 +27,114 @@ This is an example repository with tests in the `tests/examples/` directory. To 5. Create a `qase.config.json` in the root of the repository, and add your token, and project code. 6. Run `pytest`. + +## New Features & Configuration +### Test Run Tags +You can now add tags to test runs. Update your `qase.config.json`, environment variables, or CLI flags. + +```json +{ + "testops": { + "run": { + "tags": ["smoke", "regression"] + } + } +} + +``` +#### Environment variable example: +```bash +export QASE_TESTOPS_RUN_TAGS="smoke,regression" +``` +#### CLI flag example: +```bash +pytest --qase-testops-run-tags "smoke,regression" +``` +### Excluding Parameters from Results +Specify parameters to exclude from results: +```json +{ +"exclude_parameters": ["browser", "environment"] +} +``` +#### Environment variable example: +```bash +export QASE_EXCLUDE_PARAMS="browser,environment" +``` +#### CLI flag example: +```bash +pytest --qase-exclude-params "browser,environment" +``` +### Test Run Configurations +You can specify configurations for test runs via `qase.config.json`, environment variables, or CLI flags. +```json +{ + "testops": { + "configurations": { + "values": [ + { + "name": "browser", + "value": "chrome" + }, + { + "name": "environment", + "value": "staging" + } + ], + "createIfNotExists": true + } + } +} +``` + +#### Environment variable example: +```bash +export QASE_TESTOPS_CONFIGURATIONS_VALUES="browser=chrome,environment=staging" +``` +#### CLI flag example: +```bash +pytest --qase-testops-configurations-values "browser=chrome,environment=staging" +``` +`Notes:` +- Format: "group1=value1,group2=value2" +- Use createIfNotExists: true in your config file to automatically create configurations in Qase if they don’t exist. +- If not set, no configurations will be added. + +### Filtering Test Results by Status +You can filter which results to send based on status: +```json +{ + "testops": { + "statusFilter": ["passed", "failed"] + } +} +``` +#### Environment variable example: +```bash +export QASE_TESTOPS_STATUS_FILTER="passed,failed" +``` +#### CLI flag example: +```bash +pytest --qase-testops-status-filter "passed,failed" +``` +### Status Mapping +Map your local test statuses to Qase statuses: +```json +{ + "statusMapping": { + "invalid": "failed", + "skipped": "passed" + } +} +``` +#### Environment variable example: +```bash +export QASE_STATUS_MAPPING="invalid=failed,skipped=passed" +``` +#### CLI flag example: +```bash +pytest --qase-status-mapping="invalid=failed,skipped=passed" +``` +More details: Status Mapping [Docs](https://github.com/qase-tms/qase-python/blob/main/qase-python-commons/docs/STATUS_MAPPING.md) + +--- diff --git a/tests/examples/test_failed_vs_invalid.py b/tests/examples/test_failed_vs_invalid.py new file mode 100644 index 0000000..4be6975 --- /dev/null +++ b/tests/examples/test_failed_vs_invalid.py @@ -0,0 +1,23 @@ +from qase.pytest import qase +import pytest + +# --- Test that will fail due to an assertion failure --- +def test_assertion_failure(): + """ + This test will fail because the assertion is incorrect. + Qase should mark this as: FAILED + """ + result = 2 + 2 + assert result == 5, f"Expected 5 but got {result}" + + +# --- Test that will fail due to a non-assertion error --- +def test_non_assertion_failure(): + """ + This test will fail because of a runtime exception (ZeroDivisionError). + Qase should mark this as: INVALID + """ + x = 10 + y = 0 + result = x / y # Raises ZeroDivisionError + diff --git a/tests/examples/test_params.py b/tests/examples/test_params.py index 8addf35..be65274 100644 --- a/tests/examples/test_params.py +++ b/tests/examples/test_params.py @@ -80,12 +80,12 @@ def test_dynamic_qase_param(env: str): @pytest.mark.parametrize("email", ["@abc", "@xyz", "@asdf"]) @qase.parametrize_ignore("test_data", ["data1", "data2"]) -def test_with_ignored_param(browser, test_data): +def test_with_ignored_param(email, test_data): """ 'email' will appear in Qase reports. 'test_data' is used in the test but not reported to Qase. """ - assert browser in ["@abc", "@xyz", "@asdf"] + assert email in ["@abc", "@xyz", "@asdf"] assert test_data in ["data1", "data2"] - print(f"Test executed on browser: {browser} with test data: {test_data}") + print(f"Test executed on browser: {email} with test data: {test_data}") diff --git a/tests/examples/test_tags.py b/tests/examples/test_tags.py index e9ff1b5..5c3cb9c 100644 --- a/tests/examples/test_tags.py +++ b/tests/examples/test_tags.py @@ -1,6 +1,6 @@ +import pytest from qase.pytest import qase -# This method is currently *NOT* supported. -# @qase.tags("tag1", "tag2") +@qase.tags("tag1", "tag2") def test_qase_tags(): - assert True + assert True \ No newline at end of file