Skip to content

Commit

Permalink
creating Behavex v3.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
anibalinn committed Jul 30, 2024
1 parent 5b87414 commit ebd7270
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 16 deletions.
6 changes: 5 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
Version History
===============================================================================

Version: 3.2.1
Version: 3.2.2
-------------------------------------------------------------------------------
ENHANCEMENTS:

* Adding a progress bar to the console when running in parallel to better track the execution progress (arguments: -spb or --show-progress-bar)
* Adding workflow to validate the BehaveX wrapper is properly installed in latest python versions (v3.8 to v3.11)
* Updated pre-commit hooks to use them in every commit
* Removing some parameters that are no longer used

FIXES:

* Fixed blank report issue reported in some cases when running tests in parallel
* Fixed issues when performing a dry-run when there are no features/scenarios tagged as MANUAL


Version: 3.2.0
Expand Down
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ Also, there might be more arguments that can be supported, it is just a matter o
* Specifies the number of parallel Behave processes
* **parallel-scheme** (--parallel-scheme)
* Performs the parallel test execution by [scenario|feature]
* **show-progress-bar** (--show-progress-bar)
* Displays a progress bar in console while executing the tests in parallel

You can take a look at the provided examples (above in this documentation) to see how to use these arguments.

Expand All @@ -151,6 +153,8 @@ Examples:
> behavex -t @\<TAG\> --parallel-processes 5 --parallel-scheme feature
> behavex -t @\<TAG\> --parallel-processes 5 --parallel-scheme feature --show-progress-bar
When the parallel-scheme is set by **feature**, all tests within each feature will be run sequentially.

## Test execution reports
Expand Down Expand Up @@ -239,6 +243,25 @@ To avoid the re-execution to overwrite the previous test report, we suggest to p

It is important to mention that this argument doesn't work yet with parallel test executions


## Display a Progress Bar in Console

When executing tests in parallel, you can display a progress bar in the console to see the progress of the test execution.

To enable the progress bar, just add the **--show-progress-bar** argument to the command line.

Example:

> behavex -t @TAG --parallel-processes 3 --show-progress-bar
The progress bar is implemented using the **tqdm** library. You can change the progress bar format by adding the following setting in the behave configuration file:

> [tqdm]
>
> bar_format="{l_bar}{bar:10}| {n_fmt}/{total_fmt} [{elapsed}]"
>
> print_progress_in_new_lines="true"
## Show Your Support

**If you find this project helpful or interesting, we would appreciate it if you could give it a star** (:star:). It's a simple way to show your support and let us know that you find value in our work.
Expand Down
3 changes: 0 additions & 3 deletions behavex/conf_behavex.cfg
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
[output]
path=output

[screenshots]
hash_detail=0

[test_run]
tags_to_skip=
8 changes: 3 additions & 5 deletions behavex/conf_mgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ def get_config():
[output]
path=string(default="output")
[outputs]
types=string_list(default=list("html", "xml"))
[screenshots]
hash_detail=string(default="0")
[tqdm]
bar_format=string(default='{l_bar}{bar:10}| {n_fmt}/{total_fmt} [{elapsed}]')
print_progress_in_new_lines=boolean(default=True)
[test_run]
tags_to_skip=string(default="")
Expand Down
1 change: 1 addition & 0 deletions behavex/outputs/report_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ def match_for_execution(tags):
if get_param('dry_run'):
if 'BHX_MANUAL_DRY_RUN' in tags:
tags.remove('BHX_MANUAL_DRY_RUN')
if 'MANUAL' in tags:
tags.remove('MANUAL')
# Set scenario tags in filter
for tag in tags:
Expand Down
24 changes: 18 additions & 6 deletions behavex/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,15 @@ def launch_behavex():
json_reports = []
execution_codes = []
time_init = time.time()
config = conf_mgr.get_config()
features_path = os.environ.get('FEATURES_PATH')
parallel_scheme = get_param('parallel_scheme')
parallel_processes = get_param('parallel_processes')
show_progress_bar = get_param('show_progress_bar')
if get_param('dry_run'):
parallel_processes = 1
show_progress_bar = False
else:
parallel_processes = get_param('parallel_processes')
show_progress_bar = get_param('show_progress_bar')
multiprocess = (
True
if get_param('parallel_processes') > 1 and not get_param('dry_run')
Expand All @@ -174,8 +179,14 @@ def launch_behavex():
# shared variable to track scenarios that should be run but seems to be removed from execution (using scenarios.remove)
shared_removed_scenarios = manager.dict()
process_pool = multiprocessing.Pool(parallel_processes, initializer=init_multiprocessing(), initargs=(lock,))
progress_bar_format = "{l_bar}{bar:100} | {n_fmt}/{total_fmt}\n"
progress_bar = tqdm(desc="Execution Progress", bar_format=progress_bar_format) if show_progress_bar else None
if show_progress_bar:
progress_bar_format = config['tqdm']['bar_format']
print_progress_in_new_lines = config['tqdm']['print_progress_in_new_lines']
if print_progress_in_new_lines:
progress_bar_format += "\n"
progress_bar = tqdm(desc="Execution Progress", bar_format=progress_bar_format, total=0)
else:
progress_bar = None
try:
if parallel_processes == 1 or get_param('dry_run'):
# Executing without parallel processes
Expand All @@ -201,6 +212,7 @@ def launch_behavex():
)
wrap_up_process_pools(process_pool, json_reports, multiprocess, scenario)
if progress_bar:
progress_bar.disable = True
progress_bar.close()
time_end = time.time()

Expand Down Expand Up @@ -345,7 +357,7 @@ def launch_by_feature(features, process_pool, progress_bar):
parallel_features.append({"feature_filename": feature.filename,
"feature_json_skeleton": _get_feature_json_skeleton(feature)})
if progress_bar is not None:
progress_bar.reset(len(serial_features) + len(parallel_features))
progress_bar.total = len(serial_features) + len(parallel_features)
if serial_features:
print_parallel('feature.serial_execution')
for feature_filename in serial_features:
Expand Down Expand Up @@ -410,7 +422,7 @@ def launch_by_scenario(features, process_pool, lock, shared_removed_scenarios, p
parallel_scenarios[features_path].append(scenario_information)
total_scenarios += 1
if progress_bar is not None:
progress_bar.reset(total_scenarios)
progress_bar.total = total_scenarios
if duplicated_scenarios:
print_parallel('scenario.duplicated_scenarios', json.dumps(duplicated_scenarios, indent=4))
exit(1)
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name='behavex',
version='3.2.1',
version='3.2.2',
python_requires='>=3.5',
author='Hernan Rey',
author_email='[email protected]',
Expand Down Expand Up @@ -39,6 +39,7 @@
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Topic :: Software Development :: Testing',
],
)

0 comments on commit ebd7270

Please sign in to comment.