Skip to content

Commit 6df6b0a

Browse files
committed
feat: Better logging reveals what is tested and how
1 parent 6b4b6ef commit 6df6b0a

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

SchemathesisLibrary/__init__.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@
2020
from DataDriver.ReaderConfig import TestCaseData # type: ignore
2121
from hypothesis import HealthCheck, Phase, Verbosity, given, settings
2222
from hypothesis import strategies as st
23+
from robot.api import logger
2324
from robot.api.deco import keyword
2425
from robot.result.model import TestCase as ResultTestCase # type: ignore
2526
from robot.result.model import TestSuite as ResultTestSuite # type: ignore
2627
from robot.running.model import TestCase, TestSuite # type: ignore
2728
from robotlibcore import DynamicCore # type: ignore
28-
from schemathesis.core.result import Ok # type: ignore
29+
from schemathesis.core.result import Ok
2930
from schemathesis.core.transport import Response
3031

3132
__version__ = "0.1.0"
@@ -81,7 +82,20 @@ def _start_test(self, data: TestCase, result: ResultTestCase) -> None:
8182
@keyword
8283
def call_and_validate(self, case: schemathesis.Case) -> Response:
8384
"""Validate a Schemathesis case."""
84-
return case.call_and_validate()
85+
self.info(f"Case: {case.path} | {case.method} | {case.path_parameters}")
86+
self.debug(
87+
f"Case headers {case.headers!r} body {case.body!r} "
88+
f"cookies {case.cookies!r} path parameters {case.path_parameters!r}"
89+
)
90+
response = case.call_and_validate()
91+
self.debug(f"Response: {response.headers} | {response.status_code} | {response.text}")
92+
return response
93+
94+
def info(self, message: str) -> None:
95+
logger.info(message)
96+
97+
def debug(self, message: str) -> None:
98+
logger.debug(message)
8599

86100

87101
def add_examples(strategy: st.SearchStrategy, container: list[TestCaseData], max_examples: int) -> None:

tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def atest(ctx):
135135
"run",
136136
"robot",
137137
"--loglevel",
138-
"DEBUG",
138+
"DEBUG:INFO",
139139
"--pythonpath",
140140
".",
141141
"--outputdir",

0 commit comments

Comments
 (0)