Verified Commit f0b88b53 authored by Jan Miksik's avatar Jan Miksik Committed by Jan Miksik
Browse files

Added autoreporting and test repetition

- test repetition (--repeat)
- autoreporting

Autoreporting into folder ~/reports (must be already created)
Format of html report:
where [TEST PATH] is replaced for mlutiple tests or all
  if not exactly one value is present
parent 0ac39cb7
Pipeline #96934 passed with stages
in 1 minute and 24 seconds
......@@ -8,6 +8,7 @@ import selenium
import nsfarm.web
import time
logger = logging.getLogger(__package__)
......@@ -30,6 +31,17 @@ def pytest_addoption(parser):
help="Run vncviewer when ever we start selenium container.",
help="Number of times to repeat selected tests",
help="Turns off report",
......@@ -46,6 +58,18 @@ def pytest_configure(config):
setattr(config, "target_config", targets.get(config.getoption("-T")))
# Set if gui viewer should be open when testing using Selenium
nsfarm.web.Container.open_viewer = config.getoption("--viewgui")
# Add report if tags are not present
if config.getoption("--noreport") and "--html" not in config.option:
filename = time.strftime("%Y-%m-%d-%H%M")
filename += f"-{}" if else ""
filename += f"-{config.getoption('-B')}" if "branch" in config.option and config.option.branch else ""
if len(config.option.file_or_dir) > 1:
filename += "-partial"
elif len(config.option.file_or_dir) == 1:
filename += "-" + config.option.file_or_dir[0].replace("/", ".").strip(".")
filename += "-full"
config.option.htmlpath = f"~/reports/{filename}.html"
class HTMLReport:
......@@ -84,3 +108,8 @@ def screenshot(record_property):
record_property(f"png.{when}", (name, source.get_screenshot_as_base64()))
return __shot
def pytest_collection_modifyitems(session, config, items):
count = config.option.repeat
session.items[:] = session.items * count # add each test multiple times
addopts = --strict-markers
log_file = test.log
log_file_level = DEBUG
log_file_format = %(levelname)s[%(relativeCreated)d]%(name)s %(message)s
log_file_date_format = %Y/%m/%d %H:%M:%S
log_level = DEBUG
log_format = %(levelname)s[%(relativeCreated)d]%(name)s %(message)s
log_cli_format = %(levelname)s %(name)s %(message)s
......@@ -7,3 +13,4 @@ markers =
deploy: quick tests to be run as part of deployment process
board(boards): mark test to run only on specified boards
not_board(boards): mark test to not run on specified boards
debug: mark used for debugging
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment