-
Notifications
You must be signed in to change notification settings - Fork 0
/
runner.py
45 lines (41 loc) · 1.34 KB
/
runner.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import argparse
import subprocess
if __name__ == "__main__":
parser = argparse.ArgumentParser()
# commandline arguments
parser.add_argument(
"--env",
required=True,
help="The environment the tests are going to run in.",
)
parser.add_argument(
"--product",
required=True,
help="The product under test",
)
parser.add_argument(
"--tags",
required=False,
help="Tags to include or exclude. use ~tag_name to exclude tags",
)
argument = parser.parse_args()
# Convert to behave commandline args
product_tag = argument.product.lower().replace("-", "_")
if argument.tags:
tags = f" --tags {product_tag} --tags {argument.tags} "
else:
tags = f" --tags {product_tag}"
PRODUCT = f" -D product={argument.product}"
ENV = f" -D env={argument.env}"
# complete command
command = (
f"behave{PRODUCT}{ENV}"
f" -f behave_cucumber_formatter:PrettyCucumberJSONFormatter"
f" -o reports/cucumber_json.json"
f" -f allure_behave.formatter:AllureFormatter"
f" -o allure-results"
f" -f pretty features"
f" --no-logcapture --no-skipped --expand --logging-level=DEBUG{tags}"
)
print(f"Running subprocess with command: '{command}'")
subprocess.run(command, shell=True, check=True)