Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 - <br> `git clone --single-branch --branch <branch-name> https://github.com/cskmnrpt/qase-pytest.git`

Expand All @@ -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)

---
23 changes: 23 additions & 0 deletions tests/examples/test_failed_vs_invalid.py
Original file line number Diff line number Diff line change
@@ -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

6 changes: 3 additions & 3 deletions tests/examples/test_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Test Output Mismatch: Browser vs Email

The print statement in test_with_ignored_param still references "browser" in its message, even though the parameter being printed is now email. This results in misleading output that doesn't accurately describe the test's execution.

Fix in Cursor Fix in Web

6 changes: 3 additions & 3 deletions tests/examples/test_tags.py
Original file line number Diff line number Diff line change
@@ -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