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
2 changes: 1 addition & 1 deletion testit-adapter-behave/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import find_packages, setup

VERSION = "4.0.0"
VERSION = "4.1.0"

setup(
name='testit-adapter-behave',
Expand Down
11 changes: 7 additions & 4 deletions testit-adapter-behave/src/testit_adapter_behave/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from .models.test_result_step import get_test_result_step_model
from .scenario_parser import (
parse_scenario,
parse_status)
parse_step_status,
parse_status_type)
from .utils import (
convert_step_to_step_result_model,
convert_executable_test_to_test_result_model)
Expand Down Expand Up @@ -77,7 +78,7 @@ def get_step_result(self, result):
logging.debug("get_step_result")
self.__adapter_manager.on_running_started()
scope = self.get_scope()
outcome = parse_status(result.status)
outcome = parse_step_status(result.status)

self.__executable_test[scope][-1]['title'] = result.name
self.__executable_test[scope][-1]['outcome'] = outcome
Expand All @@ -96,7 +97,8 @@ def get_step_result(self, result):

if outcome != OutcomeType.PASSED:
self.__executable_test['traces'] = result.error_message
self.__executable_test['outcome'] = outcome
self.__executable_test['outcome'] = result.status
self.__executable_test['status_type'] = parse_status_type(result.status)
self.set_scenario()
return

Expand All @@ -107,7 +109,8 @@ def get_step_result(self, result):
self.__steps_count -= 1

if self.__steps_count == 0:
self.__executable_test['outcome'] = outcome
self.__executable_test['outcome'] = result.status
self.__executable_test['status_type'] = parse_status_type(result.status)
self.set_scenario()

def get_scope(self):
Expand Down
24 changes: 19 additions & 5 deletions testit-adapter-behave/src/testit_adapter_behave/scenario_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@
from enum import Enum

from testit_python_commons.models.outcome_type import OutcomeType
from testit_python_commons.models.status_type import StatusType

from .models.tags import TagType
from .tags_parser import parse_test_tags

STATUS = {
STATUS_TYPE = {
'passed': StatusType.SUCCEEDED,
'failed': StatusType.FAILED,
'error': StatusType.FAILED,
'skipped': StatusType.INCOMPLETE,
'untested': StatusType.INCOMPLETE,
'undefined': StatusType.INCOMPLETE
}
STEP_STATUS = {
'passed': OutcomeType.PASSED,
'failed': OutcomeType.FAILED,
'error': OutcomeType.FAILED,
Expand All @@ -26,6 +35,7 @@ def parse_scenario(scenario):
'autoTestName': tags[TagType.DISPLAY_NAME] if
TagType.DISPLAY_NAME in tags and tags[TagType.DISPLAY_NAME] else get_scenario_name(scenario),
'outcome': None,
'status_type': None,
'steps': [],
'stepResults': [],
'setUp': [],
Expand Down Expand Up @@ -82,8 +92,12 @@ def parse_scenario(scenario):
return executable_test


def parse_status(status):
return STATUS[status.name]
def parse_step_status(status):
return STEP_STATUS[status.name]


def parse_status_type(status):
return STATUS_TYPE[status.name]


def get_scenario_name(scenario):
Expand Down Expand Up @@ -124,9 +138,9 @@ def get_step_status(result):
return get_status(result.exception)
else:
if isinstance(result.status, Enum):
return STATUS.get(result.status.name, None)
return STEP_STATUS.get(result.status.name, None)
else:
return STATUS.get(result.status, None)
return STEP_STATUS.get(result.status, None)


def get_status(exception):
Expand Down
3 changes: 2 additions & 1 deletion testit-adapter-behave/src/testit_adapter_behave/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ def convert_executable_test_to_test_result_model(executable_test: dict) -> TestR
.set_teardown_results(executable_test['tearDownResults'])\
.set_duration(executable_test['duration'])\
.set_outcome(executable_test['outcome'])\
.set_status_type(executable_test['status_type'])\
.set_traces(executable_test['traces'])\
.set_attachments(executable_test['attachments'])\
.set_parameters(executable_test['parameters'])\
Expand All @@ -141,7 +142,7 @@ def convert_executable_test_to_test_result_model(executable_test: dict) -> TestR
.set_title(executable_test['title'])\
.set_description(executable_test['description'])\
.set_links(executable_test['links'])\
.set_result_links(executable_test['resultLinks']) \
.set_result_links(executable_test['resultLinks'])\
.set_labels(executable_test['labels']) \
.set_tags(executable_test['tags'])\
.set_work_item_ids(executable_test['workItemsID'])\
Expand Down
2 changes: 1 addition & 1 deletion testit-adapter-nose/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

VERSION = "4.0.0"
VERSION = "4.1.0"

setup(
name='testit-adapter-nose',
Expand Down
4 changes: 3 additions & 1 deletion testit-adapter-nose/src/testit_adapter_nose/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from .utils import (
form_test,
get_outcome,
convert_executable_test_to_test_result_model
convert_executable_test_to_test_result_model,
STATUS_TYPE,
)


Expand Down Expand Up @@ -38,6 +39,7 @@ def set_outcome(self, event):
outcome, message, trace = get_outcome(event)

self.__executable_test['outcome'] = outcome
self.__executable_test['status_type'] = STATUS_TYPE[outcome]
self.__executable_test['traces'] = trace

if not self.__executable_test['message']:
Expand Down
31 changes: 16 additions & 15 deletions testit-adapter-nose/src/testit_adapter_nose/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,16 @@

from testit_python_commons.models.link import Link
from testit_python_commons.models.test_result import TestResult
from testit_python_commons.models.outcome_type import OutcomeType
from testit_python_commons.models.status_type import StatusType


__ARRAY_TYPES = (frozenset, list, set, tuple,)

STATUS_TYPE = {
result.PASS: StatusType.SUCCEEDED,
result.FAIL: StatusType.FAILED,
result.ERROR: StatusType.FAILED,
result.SKIP: StatusType.INCOMPLETE,
}

def status_details(event):
message, trace = None, None
Expand All @@ -31,23 +36,17 @@ def status_details(event):


def get_outcome(event):
outcome = None
outcome = event.outcome
message = None
trace = None

if event.outcome == result.PASS and event.expected:
outcome = OutcomeType.PASSED
elif event.outcome == result.PASS and not event.expected:
outcome = OutcomeType.PASSED
if outcome == result.PASS and not event.expected:
message = "test passes unexpectedly"
elif event.outcome == result.FAIL and not event.expected:
outcome = OutcomeType.FAILED
elif outcome == result.FAIL and not event.expected:
message, trace = status_details(event)
elif event.outcome == result.ERROR:
outcome = OutcomeType.BLOCKED
elif outcome == result.ERROR:
message, trace = status_details(event)
elif event.outcome == result.SKIP:
outcome = OutcomeType.SKIPPED
elif outcome == result.SKIP:
message, trace = status_details(event)

return outcome, message, trace
Expand All @@ -73,6 +72,7 @@ def form_test(item, top_level_directory):
'resultLinks': [],
'duration': 0,
'outcome': None,
'status_type': None,
'failureReasonName': None,
'traces': None,
'attachments': [],
Expand Down Expand Up @@ -387,6 +387,7 @@ def convert_executable_test_to_test_result_model(executable_test: dict) -> TestR
.set_teardown_results(executable_test['tearDownResults'])\
.set_duration(executable_test['duration'])\
.set_outcome(executable_test['outcome'])\
.set_status_type(executable_test['status_type'])\
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

вообще по логике если мы проставляем status_type то нам не нужно проставлять outcome и status code. Логика приоритета тут status_code > status_type > outcome

.set_traces(executable_test['traces'])\
.set_attachments(executable_test['attachments'])\
.set_parameters(executable_test['parameters'])\
Expand All @@ -396,8 +397,8 @@ def convert_executable_test_to_test_result_model(executable_test: dict) -> TestR
.set_title(executable_test['title'])\
.set_description(executable_test['description'])\
.set_links(executable_test['links'])\
.set_result_links(executable_test['resultLinks']) \
.set_labels(executable_test['labels']) \
.set_result_links(executable_test['resultLinks'])\
.set_labels(executable_test['labels'])\
.set_tags(executable_test['tags'])\
.set_work_item_ids(executable_test['workItemsID'])\
.set_message(executable_test['message'])\
Expand Down
2 changes: 1 addition & 1 deletion testit-adapter-pytest/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import find_packages, setup

VERSION = "4.0.0"
VERSION = "4.1.0"

setup(
name='testit-adapter-pytest',
Expand Down
31 changes: 24 additions & 7 deletions testit-adapter-pytest/src/testit_adapter_pytest/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,25 @@

import testit_python_commons.services as adapter
from testit_python_commons.models.outcome_type import OutcomeType
from testit_python_commons.models.status_type import StatusType
from testit_python_commons.models.fixture import FixtureResult, FixturesContainer
from testit_python_commons.services import AdapterManager, StepManager, FixtureManager
from testit_python_commons.services.logger import adapter_logger

import testit_adapter_pytest.utils as utils
from testit_adapter_pytest.fixture_context import FixtureContext

STATUS = {

STATUS_TYPE = {
'passed': StatusType.SUCCEEDED,
'failed': StatusType.FAILED,
'xfailed': StatusType.FAILED,
'skipped': StatusType.INCOMPLETE,
}
STEP_STATUS = {
'passed': OutcomeType.PASSED,
'failed': OutcomeType.FAILED,
'skipped': OutcomeType.SKIPPED
'skipped': OutcomeType.SKIPPED,
}


Expand Down Expand Up @@ -233,16 +241,25 @@ def pytest_fixture_post_finalizer(self, fixturedef):
def pytest_runtest_logreport(self, report):
if self.__executable_test:
if report.when == 'setup':
self.__executable_test.outcome = STATUS.get(report.outcome, None)
self.__executable_test.outcome = report.outcome
self.__executable_test.status_type = STATUS_TYPE.get(report.outcome, None)
if report.longreprtext:
self.__executable_test.message = report.longreprtext

if report.when == 'call':
self.__executable_test.outcome = STATUS.get(report.outcome, None)
self.__executable_test.outcome = report.outcome
self.__executable_test.status_type = STATUS_TYPE.get(report.outcome, None)

if report.failed or report.outcome == 'rerun':
self.__executable_test.outcome = 'failed'
self.__executable_test.status_type = STATUS_TYPE.get('failed', None)

if report.longreprtext:
self.__executable_test.traces = report.longreprtext

if report.failed or hasattr(report, 'wasxfail') \
and not report.passed or report.outcome == 'rerun':
self.__executable_test.outcome = STATUS.get('failed', None)
if hasattr(report, 'wasxfail') and not report.passed:
self.__executable_test.outcome = 'xfailed'
self.__executable_test.status_type = STATUS_TYPE.get('xfailed', None)

if report.longreprtext:
self.__executable_test.traces = report.longreprtext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ExecutableTest:
result_links = attrib(default=Factory(list))
duration = attrib(default=None)
outcome = attrib(default=None)
status_type = attrib(default=None)
failure_reason_names = attrib(default=Factory(list))
traces = attrib(default=None)
attachments = attrib(default=Factory(list))
Expand Down
10 changes: 7 additions & 3 deletions testit-adapter-pytest/src/testit_adapter_pytest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from testit_python_commons.models.link import Link
from testit_python_commons.models.test_result import TestResult
from testit_python_commons.models.test_result_with_all_fixture_step_results_model import TestResultWithAllFixtureStepResults
from testit_python_commons.models.outcome_type import OutcomeType

from testit_adapter_pytest.models.executable_test import ExecutableTest

Expand Down Expand Up @@ -47,6 +48,8 @@ def __set_outcome_and_message_from_markers(executable_test: ExecutableTest, mark
for marker in markers:
if marker.name in ('skip', 'skipif'):
executable_test.outcome = 'Skipped'
if marker.name == 'xfail':
executable_test.outcome = 'Xfailed'
if marker.name in ('skip', 'skipif', 'xfail'):
if len(marker.args) == 1 and isinstance(marker.args, str):
executable_test.message = marker.args[0]
Expand Down Expand Up @@ -337,6 +340,7 @@ def convert_executable_test_to_test_result_model(executable_test: ExecutableTest
.set_teardown_results(executable_test.teardown_step_results)\
.set_duration(executable_test.duration)\
.set_outcome(executable_test.outcome)\
.set_status_type(executable_test.status_type)\
.set_traces(executable_test.traces)\
.set_attachments(executable_test.attachments)\
.set_parameters(executable_test.parameters)\
Expand Down Expand Up @@ -404,10 +408,10 @@ def fixtures_containers_to_test_results_with_all_fixture_step_results(
def get_status(exception):
if exception:
if isinstance(exception, pytest.skip.Exception):
return "Skipped"
return "Failed"
return OutcomeType.SKIPPED
return OutcomeType.FAILED
else:
return "Passed"
return OutcomeType.PASSED


def get_outcome_status(outcome):
Expand Down
2 changes: 1 addition & 1 deletion testit-adapter-robotframework/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import find_packages, setup

VERSION = "4.0.0"
VERSION = "4.1.0"

setup(
name='testit-adapter-robotframework',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from robot.libraries.BuiltIn import BuiltIn

from .models import Autotest
from .utils import STATUSES, convert_time, convert_executable_test_to_test_result_model, get_hash
from .utils import STEP_STATUSES, STATUS_TYPES, convert_time, convert_executable_test_to_test_result_model, get_hash


class AutotestAdapter:
Expand Down Expand Up @@ -54,13 +54,14 @@ def end_keyword(self, name, attributes):
start = convert_time(attributes['starttime'])
end = convert_time(attributes['endtime'])
duration = attributes['elapsedtime']
outcome = STATUSES[attributes['status']]
outcome = STEP_STATUSES[attributes['status']]
self.active_test.add_step_result(title, start, end, duration, outcome, self.active_test.attachments)
self.active_test.attachments = []

def end_test(self, name, attributes):
if self.active_test:
self.active_test.outcome = STATUSES[attributes['status']]
self.active_test.outcome = attributes['status']
self.active_test.status_type = STATUS_TYPES[attributes['status']]
self.active_test.started_on = convert_time(attributes['starttime'])
self.active_test.completed_on = convert_time(attributes['endtime'])
if not self.active_test.message and self.active_test.outcome == 'Failed':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ class Autotest(Default):
failureReasonNames = attrib(default=Factory(list)) # noqa: N815
traces = attrib(default=None)
outcome = attrib(default=None)
status_type = attrib(default=None)
namespace = attrib(default=None)
attachments = attrib(default=Factory(list))
parameters = attrib(default=Factory(dict))
Expand Down
Loading
Loading