Skip to content

Commit

Permalink
QE-10656 fix huge images in report (#312)
Browse files Browse the repository at this point in the history
* fix report html width so it doesn’t make images huge
* default not to show skips
   * merge skip config into one flag
* fix cucu debug command
* default not to show status for report generation
   * add newline after report generation status
* add start timestamp to scenario, feature and index
* add static totals to index and feature pages
* don't search on timestamps and totals in report pages - see
https://datatables.net/plug-ins/filtering/
* add flat index page that shows all scenarios
* add feature tags and name  to scenario page
* reduce extraneous tags in scenario page
   * move text and table into same step td
   * have only 1 pre tag for each text, table, stdout and error_message
  • Loading branch information
ddl-cedricyoung authored Mar 3, 2023
1 parent 508506c commit 6bebd18
Show file tree
Hide file tree
Showing 16 changed files with 426 additions and 215 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ _Get your repo setup using cucu as a test framework_
1. install and start Docker if you haven't already
2. add cucu your `requirements.txt` to get from GH by label (use current label number)
```
git+ssh://[email protected]/cerebrotech/cucu@0.118.0#egg=cucu
git+ssh://[email protected]/cerebrotech/cucu@0.119.0#egg=cucu
```
3. install it
```
Expand Down
127 changes: 81 additions & 46 deletions features/cli/report_basics.feature

Large diffs are not rendered by default.

62 changes: 31 additions & 31 deletions features/cli/report_search_and_sorting.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,54 @@ Feature: Report search and sorting
and use the search and sorting features as expected

Scenario: User can sort by various fields in the HTML test report
Given I run the command "cucu run data/features/tagged_features --tags @feature2 --results {CUCU_RESULTS_DIR}/sorting-in-reports-results" and expect exit code "0"
And I run the command "cucu report {CUCU_RESULTS_DIR}/sorting-in-reports-results --output {CUCU_RESULTS_DIR}/sorting-in-reports-report" and expect exit code "0"
Given I run the command "cucu run data/features/tagged_features --tags @feature2 --show-skips --results {CUCU_RESULTS_DIR}/sorting-in-reports-results" and expect exit code "0"
And I run the command "cucu report {CUCU_RESULTS_DIR}/sorting-in-reports-results --show-skips --output {CUCU_RESULTS_DIR}/sorting-in-reports-report" and expect exit code "0"
And I start a webserver at directory "{CUCU_RESULTS_DIR}/sorting-in-reports-report/" and save the port to the variable "PORT"
And I open a browser at the url "http://{HOST_ADDRESS}:{PORT}/index.html"
Then I wait to see a table that matches the following:
| Feature | Total | Passed | Failed | Skipped | Status | Duration |
| Second tagged feature | 1 | 1 | 0 | 0 | passed | .* |
| First tagged feature | 1 | 0 | 0 | 1 | skipped | .* |
| Third tagged feature | 1 | 0 | 0 | 1 | skipped | .* |
| Started at | Feature | Total | Passed | Failed | Skipped | Status | Duration |
| .* | Second tagged feature | 1 | 1 | 0 | 0 | passed | .* |
| .* | First tagged feature | 1 | 0 | 0 | 1 | skipped | .* |
| .* | Third tagged feature | 1 | 0 | 0 | 1 | skipped | .* |

Scenario: User can sort by various fields in the HTML test report and share the exact state via the URL
Given I run the command "cucu run data/features/tagged_features --tags @feature2 --results {CUCU_RESULTS_DIR}/sorting-in-reports-results" and expect exit code "0"
And I run the command "cucu report {CUCU_RESULTS_DIR}/sorting-in-reports-results --output {CUCU_RESULTS_DIR}/sorting-in-reports-report" and expect exit code "0"
Given I run the command "cucu run data/features/tagged_features --tags @feature2 --show-skips --results {CUCU_RESULTS_DIR}/sorting-in-reports-results" and expect exit code "0"
And I run the command "cucu report {CUCU_RESULTS_DIR}/sorting-in-reports-results --show-skips --output {CUCU_RESULTS_DIR}/sorting-in-reports-report" and expect exit code "0"
And I start a webserver at directory "{CUCU_RESULTS_DIR}/sorting-in-reports-report/" and save the port to the variable "PORT"
And I open a browser at the url "http://{HOST_ADDRESS}:{PORT}/index.html"
When I wait to see a table that matches the following:
| Feature | Total | Passed | Failed | Skipped | Status | Duration |
| Second tagged feature | 1 | 1 | 0 | 0 | passed | .* |
| First tagged feature | 1 | 0 | 0 | 1 | skipped | .* |
| Third tagged feature | 1 | 0 | 0 | 1 | skipped | .* |
| Started at | Feature | Total | Passed | Failed | Skipped | Status | Duration |
| .* | Second tagged feature | 1 | 1 | 0 | 0 | passed | .* |
| .* | First tagged feature | 1 | 0 | 0 | 1 | skipped | .* |
| .* | Third tagged feature | 1 | 0 | 0 | 1 | skipped | .* |
And I click the table header "Status"
And I wait to see a table that matches the following:
| Feature | Total | Passed | Failed | Skipped | Status | Duration |
| First tagged feature | 1 | 0 | 0 | 1 | skipped | .* |
| Third tagged feature | 1 | 0 | 0 | 1 | skipped | .* |
| Second tagged feature | 1 | 1 | 0 | 0 | passed | .* |
| Started at | Feature | Total | Passed | Failed | Skipped | Status | Duration |
| .* | First tagged feature | 1 | 0 | 0 | 1 | skipped | .* |
| .* | Third tagged feature | 1 | 0 | 0 | 1 | skipped | .* |
| .* | Second tagged feature | 1 | 1 | 0 | 0 | passed | .* |
And I save the current url to the variable "CURRENT_URL"
And I refresh the browser
Then I wait to see a table that matches the following:
| Feature | Total | Passed | Failed | Skipped | Status | Duration |
| First tagged feature | 1 | 0 | 0 | 1 | skipped | .* |
| Third tagged feature | 1 | 0 | 0 | 1 | skipped | .* |
| Second tagged feature | 1 | 1 | 0 | 0 | passed | .* |
| Started at | Feature | Total | Passed | Failed | Skipped | Status | Duration |
| .* | First tagged feature | 1 | 0 | 0 | 1 | skipped | .* |
| .* | Third tagged feature | 1 | 0 | 0 | 1 | skipped | .* |
| .* | Second tagged feature | 1 | 1 | 0 | 0 | passed | .* |

Scenario: User can search by various fields in the HTML test report
Given I run the command "cucu run data/features/tagged_features --tags @feature2 --results {CUCU_RESULTS_DIR}/searching-in-reports-results" and expect exit code "0"
And I run the command "cucu report {CUCU_RESULTS_DIR}/searching-in-reports-results --output {CUCU_RESULTS_DIR}/searching-in-reports-report" and expect exit code "0"
Given I run the command "cucu run data/features/tagged_features --tags @feature2 --show-skips --results {CUCU_RESULTS_DIR}/searching-in-reports-results" and expect exit code "0"
And I run the command "cucu report {CUCU_RESULTS_DIR}/searching-in-reports-results --show-skips --output {CUCU_RESULTS_DIR}/searching-in-reports-report" and expect exit code "0"
And I start a webserver at directory "{CUCU_RESULTS_DIR}/searching-in-reports-report/" and save the port to the variable "PORT"
And I open a browser at the url "http://{HOST_ADDRESS}:{PORT}/index.html"
When I write "passed" into the input "Search:"
Then I wait to see a table that matches the following:
| Feature | Total | Passed | Failed | Skipped | Status | Duration |
| Second tagged feature | 1 | 1 | 0 | 0 | passed | .* |
| Started at | Feature | Total | Passed | Failed | Skipped | Status | Duration |
| .* | Second tagged feature | 1 | 1 | 0 | 0 | passed | .* |
When I write "skipped" into the input "Search:"
Then I wait to see a table that matches the following:
| Feature | Total | Passed | Failed | Skipped | Status | Duration |
| First tagged feature | 1 | 0 | 0 | 1 | skipped | .* |
| Third tagged feature | 1 | 0 | 0 | 1 | skipped | .* |
| Started at | Feature | Total | Passed | Failed | Skipped | Status | Duration |
| .* | First tagged feature | 1 | 0 | 0 | 1 | skipped | .* |
| .* | Third tagged feature | 1 | 0 | 0 | 1 | skipped | .* |

Scenario: User can search by various fields in the HTML test report and share the exact state via the URL
Given I run the command "cucu run data/features/tagged_features --tags @feature2 --results {CUCU_RESULTS_DIR}/searching-in-reports-results" and expect exit code "0"
Expand All @@ -60,10 +60,10 @@ Feature: Report search and sorting
And I open a browser at the url "http://{HOST_ADDRESS}:{PORT}/index.html"
When I write "passed" into the input "Search:"
Then I wait to see a table that matches the following:
| Feature | Total | Passed | Failed | Skipped | Status | Duration |
| Second tagged feature | 1 | 1 | 0 | 0 | passed | .* |
| Started at | Feature | Total | Passed | Failed | Skipped | Status | Duration |
| .* | Second tagged feature | 1 | 1 | 0 | 0 | passed | .* |
When I save the current url to the variable "CURRENT_URL"
And I refresh the browser
Then I wait to see a table that matches the following:
| Feature | Total | Passed | Failed | Skipped | Status | Duration |
| Second tagged feature | 1 | 1 | 0 | 0 | passed | .* |
| Started at | Feature | Total | Passed | Failed | Skipped | Status | Duration |
| .* | Second tagged feature | 1 | 1 | 0 | 0 | passed | .* |
2 changes: 1 addition & 1 deletion features/cli/run_outputs.feature
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ Feature: Run outputs
And I should see "{STDERR}" is empty

Scenario: User gets JUnit XML results file as expected
Given I run the command "cucu run data/features/feature_with_mixed_results.feature --results {CUCU_RESULTS_DIR}/validate_junit_xml_results" and save stdout to "STDOUT" and expect exit code "1"
Given I run the command "cucu run data/features/feature_with_mixed_results.feature --show-skips --results {CUCU_RESULTS_DIR}/validate_junit_xml_results" and save stdout to "STDOUT" and expect exit code "1"
Then I should see a file at "{CUCU_RESULTS_DIR}/validate_junit_xml_results/TESTS-Feature_with_mixed_results.xml"
And I should see the file at "{CUCU_RESULTS_DIR}/validate_junit_xml_results/TESTS-Feature_with_mixed_results.xml" matches the following:
"""
Expand Down
4 changes: 2 additions & 2 deletions features/cli/run_with_tags.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Feature: Run with tags
run.

Scenario: User can run a specific feature using a tag
Given I run the command "cucu run data/features/feature_with_tagging.feature --tags '@second' --results {CUCU_RESULTS_DIR}/scenario_with_tag_results" and save stdout to "STDOUT", stderr to "STDERR" and expect exit code "0"
Given I run the command "cucu run data/features/feature_with_tagging.feature --tags '@second' --show-skips --results {CUCU_RESULTS_DIR}/scenario_with_tag_results" and save stdout to "STDOUT", stderr to "STDERR" and expect exit code "0"
Then I should see "{STDOUT}" matches the following
"""
@all
Expand All @@ -29,7 +29,7 @@ Feature: Run with tags
And I should see "{STDERR}" is empty

Scenario: User can exclude a specific feature using a tag
Given I run the command "cucu run data/features/feature_with_tagging.feature --tags '~@second' --results {CUCU_RESULTS_DIR}/scenario_without_tag_results" and save stdout to "STDOUT", stderr to "STDERR" and expect exit code "0"
Given I run the command "cucu run data/features/feature_with_tagging.feature --tags '~@second' --show-skips --results {CUCU_RESULTS_DIR}/scenario_without_tag_results" and save stdout to "STDOUT", stderr to "STDERR" and expect exit code "0"
Then I should see "{STDOUT}" matches the following
"""
@all
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cucu"
version = "0.118.0"
version = "0.119.0"
license = "MIT"
description = ""
authors = ["Rodney Gomes <[email protected]>"]
Expand Down
73 changes: 52 additions & 21 deletions src/cucu/cli/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,6 @@ def main():
help="specify the output directory for JUnit XML files, default is "
"the same location as --results",
)
@click.option(
"--junit-without-skips",
is_flag=True,
default=False,
help="when set to true skipped results are removed from the JUnit results",
)
@click.option(
"--junit-with-stacktrace",
is_flag=True,
Expand All @@ -117,6 +111,18 @@ def main():
default="INFO",
help="set logging level to one of debug, warn or info (default)",
)
@click.option(
"--show-skips",
default=False,
is_flag=True,
help="when set skips are shown",
)
@click.option(
"--show-status",
default=False,
is_flag=True,
help="when set status output is shown (helpful for CI that wants stdout updates)",
)
@click.option(
"--periodic-thread-dumper",
default=None,
Expand All @@ -139,12 +145,6 @@ def main():
is_flag=True,
help="when set the HTML test report will only contain the failed test results",
)
@click.option(
"--report-without-skips",
is_flag=True,
default=False,
help="when set to true skipped results are removed from the tests report",
)
@click.option(
"-r",
"--results",
Expand Down Expand Up @@ -200,17 +200,17 @@ def run(
name,
ipdb_on_failure,
junit,
junit_without_skips,
junit_with_stacktrace,
logging_level,
periodic_thread_dumper,
preserve_results,
report,
report_only_failures,
report_without_skips,
results,
runtime_timeout,
secrets,
show_skips,
show_status,
tags,
selenium_remote_url,
workers,
Expand Down Expand Up @@ -261,15 +261,15 @@ def run(
if junit is None:
junit = results

if junit_without_skips:
os.environ["CUCU_JUNIT_WITHOUT_SKIPS"] = "true"
if show_skips:
os.environ["CUCU_SHOW_SKIPS"] = "true"

if show_status:
os.environ["CUCU_SHOW_STATUS"] = "true"

if junit_with_stacktrace:
os.environ["CUCU_JUNIT_WITH_STACKTRACE"] = "true"

if report_without_skips:
os.environ["CUCU_REPORT_WITHOUT_SKIPS"] = "true"

if report_only_failures:
os.environ["CUCU_REPORT_ONLY_FAILURES"] = "true"

Expand Down Expand Up @@ -307,6 +307,7 @@ def cancel_timer(_):
junit,
results,
secrets,
show_skips,
tags,
verbose,
skip_init_global_hook_variables=True,
Expand Down Expand Up @@ -365,6 +366,7 @@ def cancel_timer(_):
junit,
results,
secrets,
show_skips,
tags,
verbose,
],
Expand Down Expand Up @@ -435,8 +437,22 @@ def _generate_report(filepath, output, only_failures: False):
default="INFO",
help="set logging level to one of debug, warn or info (default)",
)
@click.option(
"--show-skips",
default=False,
is_flag=True,
help="when set skips are shown",
)
@click.option(
"--show-status",
default=False,
is_flag=True,
help="when set status output is shown (helpful for CI that wants stdout updates)",
)
@click.option("-o", "--output", default="report")
def report(filepath, only_failures, logging_level, output):
def report(
filepath, only_failures, logging_level, show_skips, show_status, output
):
"""
generate a test report from a results directory
"""
Expand All @@ -445,6 +461,12 @@ def report(filepath, only_failures, logging_level, output):
os.environ["CUCU_LOGGING_LEVEL"] = logging_level.upper()
logger.init_logging(logging_level.upper())

if show_skips:
os.environ["CUCU_SHOW_SKIPS"] = "true"

if show_status:
os.environ["CUCU_SHOW_STATUS"] = "true"

run_details_filepath = os.path.join(filepath, "run_details.json")

if os.path.exists(run_details_filepath):
Expand Down Expand Up @@ -634,10 +656,19 @@ def vars(filepath):
help="when set to detach the browser will continue to run and "
"the cucu process will exit",
)
def debug(browser, url, detach):
@click.option(
"-l",
"--logging-level",
default="INFO",
help="set logging level to one of debug, warn or info (default)",
)
def debug(browser, url, detach, logging_level):
"""
debug cucu library
"""
os.environ["CUCU_LOGGING_LEVEL"] = logging_level.upper()
logger.init_logging(logging_level.upper())

fuzzy_js = fuzzy.load_jquery_lib() + fuzzy.load_fuzzy_lib()
# XXX: need to make this more generic once we make the underlying
# browser framework swappable.
Expand Down
4 changes: 4 additions & 0 deletions src/cucu/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def behave(
junit,
results,
secrets,
show_skips,
tags,
verbose,
redirect_output=False,
Expand Down Expand Up @@ -131,6 +132,9 @@ def behave(
if fail_fast:
args.append("--stop")

if not show_skips:
args.append("--no-skipped")

args.append(filepath)

result = 0
Expand Down
3 changes: 1 addition & 2 deletions src/cucu/formatter/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,7 @@ def write_json_feature(self, feature_data):
for x in feature_data["elements"]
if x["keyword"] == "Scenario"
and (
not (CONFIG["CUCU_REPORT_WITHOUT_SKIPS"])
or x["status"] != "skipped"
CONFIG["CUCU_SHOW_SKIPS"] == "true" or x["status"] != "skipped"
)
]

Expand Down
2 changes: 1 addition & 1 deletion src/cucu/formatter/junit.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def attributes(self, tag):

scenarios = results["scenarios"]

if CONFIG["CUCU_JUNIT_WITHOUT_SKIPS"]:
if CONFIG["CUCU_SHOW_SKIPS"] != "true":
filtered_scenarios = {}

for name, scenario in scenarios.items():
Expand Down
Loading

0 comments on commit 6bebd18

Please sign in to comment.