Step execution report.
| 21 | |
| 22 | |
| 23 | class StepReport: |
| 24 | """Step execution report.""" |
| 25 | |
| 26 | failed = False |
| 27 | stopped = None |
| 28 | |
| 29 | def __init__(self, step: Step) -> None: |
| 30 | """Step report constructor. |
| 31 | |
| 32 | :param pytest_bdd.parser.Step step: Step. |
| 33 | """ |
| 34 | self.step = step |
| 35 | self.started = time.perf_counter() |
| 36 | |
| 37 | def serialize(self) -> dict[str, Any]: |
| 38 | """Serialize the step execution report. |
| 39 | |
| 40 | :return: Serialized step execution report. |
| 41 | :rtype: dict |
| 42 | """ |
| 43 | return { |
| 44 | "name": self.step.name, |
| 45 | "type": self.step.type, |
| 46 | "keyword": self.step.keyword, |
| 47 | "line_number": self.step.line_number, |
| 48 | "failed": self.failed, |
| 49 | "duration": self.duration, |
| 50 | } |
| 51 | |
| 52 | def finalize(self, failed: bool) -> None: |
| 53 | """Stop collecting information and finalize the report. |
| 54 | |
| 55 | :param bool failed: Whether the step execution is failed. |
| 56 | """ |
| 57 | self.stopped = time.perf_counter() |
| 58 | self.failed = failed |
| 59 | |
| 60 | @property |
| 61 | def duration(self) -> float: |
| 62 | """Step execution duration. |
| 63 | |
| 64 | :return: Step execution duration. |
| 65 | :rtype: float |
| 66 | """ |
| 67 | if self.stopped is None: |
| 68 | return 0 |
| 69 | |
| 70 | return self.stopped - self.started |
| 71 | |
| 72 | |
| 73 | class ScenarioReport: |
no outgoing calls
no test coverage detected
searching dependent graphs…