Skip to content

Commit

Permalink
feat: support qase.params tag
Browse files Browse the repository at this point in the history
You can specify the params that you want to send to Qase.

```robotframework
*** Variables ***
${var1}            1
${var2}            1
${var3}            2

*** Test Cases ***
Simple test
    [Arguments]    ${var1}    ${var2}   ${var3}
    [Tags]     qase.params:[var1, var2]
    Should Be Equal As Numbers    ${var1}    ${var2}
    Should Be Equal As Numbers    ${var3}    ${var3}
```

Only `var1` and `var2` will be sent to Qase.
  • Loading branch information
gibiw committed Nov 20, 2024
1 parent 476892d commit 75d58b4
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 12 deletions.
2 changes: 1 addition & 1 deletion qase-python-commons/changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# [email protected].0
# [email protected].1

## What's new

Expand Down
34 changes: 29 additions & 5 deletions qase-robotframework/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Configuration options are described in the

```json
{
"mode": "testops",
"mode": "testops",
"fallback": "report",
"debug": true,
"testops": {
Expand All @@ -45,25 +45,25 @@ Configuration options are described in the
"size": 100
}
},
"report": {
"report": {
"driver": "local",
"connection": {
"local": {
"path": "./build/qase-report",
"format": "json"
"format": "json"
}
}
},
"environment": "local"
}
```


## Usage

### Link tests with test cases in Qase TestOps

To link the automated tests with the test cases in Qase TestOps, use the tags in form like `Q-<case id without project code>`.
To link the automated tests with the test cases in Qase TestOps, use the tags in form like
`Q-<case id without project code>`.
Example:

```robotframework
Expand Down Expand Up @@ -96,6 +96,7 @@ Subtraction 12 - 2 - 2 8
Listener supports reporting steps results:

Example:

```robotframework
Quick Get A JSON Body Test ## Test case: "Quick Get A JSON Body Test"
[Tags] Q-3
Expand All @@ -107,7 +108,30 @@ Initializing the test case ## T
Set To Dictionary ${info} field1=A sample string ## 1-st step - "Set To Dictionary"
```

### Working with parameters

Listener supports reporting parameters:

Example:

```robotframework
*** Variables ***
${var1} 1
${var2} 1
${var3} 2
*** Test Cases ***
Simple test
[Arguments] ${var1} ${var2} ${var3}
[Tags] qase.params:[var1, var2]
Should Be Equal As Numbers ${var1} ${var2}
Should Be Equal As Numbers ${var3} ${var3}
```

Only `var1` and `var2` will be sent to Qase.

### Execution:

```
robot --listener qase.robotframework.Listener someTest.robot
```
24 changes: 23 additions & 1 deletion qase-robotframework/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
# qase-robotframework 3.2.2

## What's new

Support `qase.params` tag. You can specify the params that you want to send to Qase.

```robotframework
*** Variables ***
${var1} 1
${var2} 1
${var3} 2
*** Test Cases ***
Simple test
[Arguments] ${var1} ${var2} ${var3}
[Tags] qase.params:[var1, var2]
Should Be Equal As Numbers ${var1} ${var2}
Should Be Equal As Numbers ${var3} ${var3}
```

Only `var1` and `var2` will be sent to Qase.

# qase-robotframework 3.2.1

## What's new
Expand Down Expand Up @@ -25,7 +47,7 @@ Formatted Return
RETURN ${value}
```

Previously, the `RETURN` keyword was presented as `RETURN` in the Qase test run.
Previously, the `RETURN` keyword was presented as `RETURN` in the Qase test run.
Now, the keyword is presented as `RETURN ${value}`.

# qase-robotframework 3.2.0b2
Expand Down
4 changes: 2 additions & 2 deletions qase-robotframework/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "qase-robotframework"
version = "3.2.1"
version = "3.2.2"
description = "Qase Robot Framework Plugin"
readme = "README.md"
authors = [{name = "Qase Team", email = "[email protected]"}]
Expand All @@ -17,7 +17,7 @@ classifiers = [
urls = {"Homepage" = "https://github.com/qase-tms/qase-python/tree/master/qase-robotframework"}
requires-python = ">=3.7"
dependencies = [
"qase-python-commons~=3.2.0",
"qase-python-commons~=3.2.1",
"filelock~=3.12.2",
]

Expand Down
9 changes: 6 additions & 3 deletions qase-robotframework/src/qase/robotframework/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def __init__(self):
config = ConfigManager()
self.reporter = QaseCoreReporter(config)
self.runtime = QaseRuntimeSingleton.get_instance()
self.step_uuid = None
self.tests = {}
self.pabot_index = None

Expand Down Expand Up @@ -81,8 +80,6 @@ def start_test(self, test, result):
def end_test(self, test, result):
logger.debug("Finishing test '%s'", test.name)

self.step_uuid = None

test_metadata = TagParser.parse_tags(test.tags)

if test_metadata.ignore:
Expand All @@ -100,6 +97,12 @@ def end_test(self, test, result):
steps = self.__parse_steps(result)
self.runtime.result.add_steps(steps)

if len(test_metadata.params) > 0:
params: dict = {}
for param in test_metadata.params:
params[param] = BuiltIn().get_variable_value(f"${{{param}}}")
self.runtime.result.params = params

if hasattr(test, "doc"):
self.runtime.result.add_field(Field("description", test.doc))

Expand Down
2 changes: 2 additions & 0 deletions qase-robotframework/src/qase/robotframework/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ class TestMetadata:
qase_id: Union[int, None]
ignore: bool
fields: dict
params: list[str]

def __init__(self) -> None:
self.qase_id = None
self.ignore = False
self.fields = {}
self.params = []
13 changes: 13 additions & 0 deletions qase-robotframework/src/qase/robotframework/tag_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ def parse_tags(tags: list[str]) -> TestMetadata:
if tag.lower().startswith("qase.fields"):
metadata.fields = TagParser.__extract_fields(tag)

if tag.lower().startswith("qase.params"):
metadata.params = TagParser.__extract_params(tag)

return metadata

@staticmethod
Expand All @@ -39,3 +42,13 @@ def __extract_fields(tag: str) -> dict:
except ValueError as e:
TagParser.__logger.error(f"Error parsing fields from tag '{tag}': {e}")
return {}

@staticmethod
def __extract_params(tag: str) -> list[str]:
value = tag.split(':', 1)[-1].strip()
try:
return [item.strip() for item in value[1:-1].split(",")]
# return value.replace('[', '').replace(']', '').split(',')
except ValueError as e:
TagParser.__logger.error(f"Error parsing params from tag '{tag}': {e}")
return []

0 comments on commit 75d58b4

Please sign in to comment.