Skip to content
Merged
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
3 changes: 2 additions & 1 deletion src/js/code/jest/id.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const { qase } = require("jest-qase-reporter/jest");

//describe("Example: id.test.js", () => {
// // Please, change the Id from `1` to any case Id present in your project before uncommenting the test.
//ANCHOR:syntax
test(qase(1, "A test with Qase Id"), () => {
// // test logic here
// });
//ANCHOR_END:syntax
//});
//});
2 changes: 1 addition & 1 deletion src/js/code/jest/ignore.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ const { qase } = require("jest-qase-reporter/jest");
//// test logic here
// });
//});
//ANCHOR_END:syntax
//ANCHOR_END:syntax
72 changes: 72 additions & 0 deletions src/py/changelog/changelog-pytest.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,80 @@

> For the most up-to-date changelog, please check our [GitHub repository](https://github.com/qase-tms/qase-python/blob/main/qase-pytest/changelog.md).

# qase-pytest 6.2.0

## What's new

Updated `qase.id()` decorator to support a list of integers, allowing one test to be linked to multiple test cases.

```python
@qase.id([2, 3])
def test_example():
pass
```

# qase-pytest 6.1.15

## What's new

Resolved an issue where a failure message for attachment uploads was displayed even when attachments were disabled in
the configuration.

# qase-pytest 6.1.14

## What's new

Resolved an issue in the pytest plugin where an KeyError ('browser_name') could
occur during pytest_runtest_makereport.

# qase-pytest 6.1.13

## What's new

Resolved an issue in the pytest plugin where an AttributeError ('BookingForm' object has no attribute 'video') could
occur during pytest_runtest_makereport.

# qase-pytest 6.1.12

## What's new

1. Removed unsupported `tags` decorator as our API does not support working with tags.
2. Fixed an issue where data was not passed correctly when using `author` and `muted` decorators.

# qase-pytest 6.1.11

## What's new

Fixed issues with using `pytest.xfail` and the `skipif` mark:

1. Custom statuses did not work when using `pytest.xfail` within the test body.
2. The status was incorrect when using the `skipif` mark.

# qase-pytest 6.1.10

## What's new

The ability to override statuses for tests marked with the `xfail` marker has been added. By default, failed tests are
assigned the `skipped` status, and passed tests are assigned the `passed` status. Custom statuses can be specified by
providing the slug of the desired status in the configuration. Configuration values can be set via `qase.config.json` or
environment variables:

- `QASE_PYTEST_XFAIL_STATUS_XFAIL`
- `QASE_PYTEST_XFAIL_STATUS_XPASS`

```diff
{ ...,
"framework": {
"pytest": {
"captureLogs": true,
+ "xfailStatus": {
+ "xfail": "skipped",
+ "xpass": "passed"
+ }
+ }
}
}
```

## 6.1.9

Expand Down
33 changes: 33 additions & 0 deletions src/py/code/pytest/test_attach.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,36 @@ def step_with_attachment():
def test_with_step_attachment():
step_with_attachment()
assert 1 == 1

import os
from qase.pytest import qase

//ANCHOR:syntax

def test_inline_attachment():
#Test attaching an inline file.
qase.attach(
(str.encode("Sample text attachment"), "text/plain", "Inline-Attachment.txt")
)
//# test logic here

def test_external_attachment():
#Test attaching an external file.
file_path = os.path.join(os.getcwd(), "path/to/test-file.txt") # Update path
qase.attach(file_path)
//# test logic here

@qase.step("Step with attachment")
def step_with_attachment():
#Step demonstrating an attachment.
qase.attach(
(str.encode("Sample text attachment"), "text/plain", "sample.txt")
)
//# test logic here

def test_with_step_attachment():
#Test including a step with an attachment.
step_with_attachment()
// # test logic here

//ANCHOR_END:syntax
8 changes: 4 additions & 4 deletions src/py/code/pytest/test_author.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from qase.pytest import qase


@qase.author("Bret S")
//ANCHOR:syntax
@qase.author("username") #make sure to provide correct 'username'
def test_qase_author():
assert True
//#test logic here
//ANCHOR_END:syntax
107 changes: 29 additions & 78 deletions src/py/code/pytest/test_fields.py
Original file line number Diff line number Diff line change
@@ -1,112 +1,63 @@
import pytest
from qase.pytest import qase


def load_markdown_content():
with open("tests/examples/markdown.md", "r") as file:
return file.read()

markdown_content = load_markdown_content()

markdowncontent = load_markdown_content()

// ANCHOR:syntax

class Test_Priority:
@qase.title("Test case with field: Priority - low")
class TestPriority:
@qase.title("Test case with Priority - Low")
@qase.priority("low")
def test_priority_low(self):
assert True, "Test failed with priority: low"

@qase.title("Test case with field: Priority - medium")
@qase.priority("medium")
def test_priority_medium(self):
assert True, "Test failed with priority: medium"
//# test logic here

@qase.title("Test case with field: Priority - high")
@qase.title("Test case with Priority - High")
@qase.priority("high")
def test_priority_high(self):
assert True, "Test failed with priority: high"


class Test_Severity:
@qase.title("Test case with field: Severity - trivial")
@qase.severity("trivial")
def test_severity_trivial(self):
assert True, "Test failed with severity: trivial"
//# test logic here

@qase.title("Test case with field: Severity - minor")
@qase.severity("minor")
def test_severity_minor(self):
assert True, "Test failed with severity: minor"

@qase.title("Test case with field: Severity - normal")
@qase.severity("normal")
def test_severity_normal(self):
assert True, "Test failed with severity: normal"

@qase.title("Test case with field: Severity - major")
@qase.severity("major")
def test_severity_major(self):
assert True, "Test failed with severity: major"

@qase.title("Test case with field: Severity - critical")
class TestSeverity:
@qase.title("Test case with Severity - Critical")
@qase.severity("critical")
def test_severity_critical(self):
assert True, "Test failed with severity: critical"

@qase.title("Test case with field: Severity - blocker")
@qase.severity("blocker")
def test_severity_blocker(self):
assert True, "Test failed with severity: blocker"
//# test logic here


class Test_Layer:
@qase.title("Test case with field: Layer - e2e")
@qase.layer("e2e")
def test_layer_e2e(self):
assert True, "Test failed with layer: e2e"

@qase.title("Test case with field: Layer - api")
class TestLayer:
@qase.title("Test case with Layer - API")
@qase.layer("api")
def test_layer_api(self):
assert True, "Test failed with layer: api"

@qase.title("Test case with field: Layer - unit")
@qase.layer("unit")
def test_layer_unit(self):
assert True, "Test failed with layer: unit"

//# test logic here

class Test_Description:
class TestMetadataFields:
@qase.title("Test case with Description field")
@qase.description(markdowncontent)
@qase.description(markdown_content)
def test_description(self):
assert markdowncontent is not None, "Description content is empty"
//# test logic here


class Test_Preconditions:
@qase.title("Test case with Preconditions field")
@qase.preconditions(markdowncontent)
@qase.preconditions(markdown_content)
def test_preconditions(self):
assert markdowncontent is not None, "Preconditions content is empty"

//# test logic here

class Test_Postconditions:
@qase.title("Test case with Postconditions field")
@qase.postconditions(markdowncontent)
@qase.postconditions(markdown_content)
def test_postconditions(self):
assert markdowncontent is not None, "Postconditions content is empty"


class Test_All_Fields:
@qase.title("Test cases with all fields")
//# test logic here

class TestAllFields:
@qase.title("Test case with multiple fields")
@qase.fields(
("severity", "normal"),
("custom_field", "value"),
("priority", "high"),
("layer", "unit"),
("description", "Try logging to Qase TestOps using login and password"),
("preconditions", "*Precondition 1*. Markdown is supported."),
("postconditions", "*Postcondition 1*. Markdown is supported."),
("description", "Example description"),
("preconditions", "Precondition example."),
("postconditions", "Postcondition example."),
)
def test_with_fields_success(self):
assert 1 == 1
def test_with_all_fields(self):
//# test logic here
// ANCHOR_END:syntax
11 changes: 8 additions & 3 deletions src/py/code/pytest/test_id.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
from qase.pytest import qase


# @qase.id(1) # Please, replace the id (1), with an existing test case Id from your project.
// ANCHOR:syntax
@qase.id(1) # Please, replace the id (1), with an existing test case Id from your project.
def test_qase_id():
assert True
// //test logic here

@qase.id([2, 3]) # The result of this test case will be posted against the linked test cases.
def test_multiple_qase_id():
// //test logic here
// ANCHOR_END:syntax
9 changes: 9 additions & 0 deletions src/py/code/pytest/test_ignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,12 @@
@qase.title("This test is executed by Pytest, but not reported to qase")
def test_qase_ignore():
assert True

from qase.pytest import qase

// ANCHOR:syntax
@qase.ignore()
@qase.title("This test runs in Pytest but is not reported to Qase")
def test_ignored_by_qase():
//# test logic here
// ANCHOR_END:syntax
6 changes: 3 additions & 3 deletions src/py/code/pytest/test_muted.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from qase.pytest import qase


//ANCHOR:syntax
@qase.muted()
@qase.title("This test shall be marked as 'Muted', in Qase")
def test_qase_title():
assert True
//#test logic here
//ANCHOR_END:syntax
47 changes: 10 additions & 37 deletions src/py/code/pytest/test_params.py
Original file line number Diff line number Diff line change
@@ -1,47 +1,20 @@
import pytest
from qase.pytest import qase


// ANCHOR:syntax
# First test using parametrization to check different values.
@pytest.mark.parametrize("Parameter", ["Value 1", "Value 2"])
def test_with_parameter(Parameter: str):
"""
This test checks the system's reaction to different parameter values. In this case,
we test with "Value 1" and "Value 2". The behavior of the system should vary depending
on the parameter value.
"""

assert Parameter in ["Value 1", "Value 2"], f"Unexpected parameter: {Parameter}"
print(f"Test executed with parameter: {Parameter}")

@pytest.mark.parametrize("parameter", ["Value 1", "Value 2"])
def test_with_parameter(parameter: str):
#Test with different parameter values.
//# test logic here

@pytest.mark.parametrize(
"username, password",
[
pytest.param("@alice", "pass123", id="Alice B"),
pytest.param("@bob", "pass456", id="Bob C"),
pytest.param("User1", "password1", id="User1 Login"),
pytest.param("User2", "password2", id="User2 Login"),
],
)
def test_group_parameters(username: str, password: str):
"""
This test simulates logging in with different user credentials. It checks if the login
process behaves correctly for different users with different usernames and passwords.
"""

assert isinstance(
username, str
), f"Expected string for username, got {type(username)}"
assert isinstance(
password, str
), f"Expected string for password, got {type(password)}"

if username == "@alice":
assert (
password == "pass123"
), f"Expected password for Alice is 'pass123', got {password}"
elif username == "@bob":
assert (
password == "pass456"
), f"Expected password for Bob is 'pass456', got {password}"

print(f"Test executed for user: {username} with password: {password}")
#Test with multiple user credentials.
//# test logic here
// ANCHOR_END:syntax
Loading