diff --git a/.gitignore b/.gitignore index 50274f4d9..31b8d65a8 100644 --- a/.gitignore +++ b/.gitignore @@ -51,4 +51,8 @@ auditjs.html auditpy.txt /venv/ .scannerwork/ -web/coverage/ \ No newline at end of file +web/coverage/ +web/.coverage +web/regression/.coverage +web/regression/covhtml/ +web/regression/htmlcov/ diff --git a/docs/en_US/release_notes_4_29.rst b/docs/en_US/release_notes_4_29.rst index 727e8aba5..a323b83fb 100644 --- a/docs/en_US/release_notes_4_29.rst +++ b/docs/en_US/release_notes_4_29.rst @@ -17,6 +17,7 @@ Housekeeping | `Issue #5337 `_ - Improve code coverage and API test cases for Views and Materialized Views. | `Issue #5343 `_ - Improve code coverage and API test cases for Debugger. | `Issue #6033 `_ - Update the cryptography python package for Python 3.5 and above. +| `Issue #6062 `_ - Ensure that code coverage should cover class and function declarations. Bug fixes ********* diff --git a/web/regression/README b/web/regression/README index a17bd955d..c52ef9478 100644 --- a/web/regression/README +++ b/web/regression/README @@ -279,13 +279,16 @@ How to generate code coverage report for API test-suite? - Run coverage With all modules - run 'python runtests.py --coverage --exclude feature_tests' + run `coverage run ./runtests.py --exclude feature_tests` With specific module - run 'python runtests.py --pkg browser.server_groups.servers.tests --coverage' + run `coverage run ./runtests.py --exclude feature_tests --pkg browser.server_groups.servers.tests` -- After execution of coverage, we will see code coverage report on console. - For a nicer presentation, '/regression/covhtml' directory gets created. - Open 'index.html' file in browser and you will see detail coverage report. +- After execution of coverage, you can run the following to see the code coverage report: + Normal report: + run `coverage report` + HTML report: + run `coverage html` + This will create a directory 'htmlcov'. Open 'index.html' file in browser and you will see detail coverage report. Javascript Tests: diff --git a/web/regression/runtests.py b/web/regression/runtests.py index 6b1d3171e..a62358fac 100644 --- a/web/regression/runtests.py +++ b/web/regression/runtests.py @@ -19,7 +19,6 @@ import sys import traceback import json import random -import coverage import threading import time import unittest @@ -49,8 +48,6 @@ if sys.path[0] != root: from pgadmin import create_app import config -COVERAGE_CONFIG_FILE = os.path.join(CURRENT_PATH, ".coveragerc") - if config.SERVER_MODE is True: config.SECURITY_RECOVERABLE = True config.SECURITY_CHANGEABLE = True @@ -357,8 +354,6 @@ def add_arguments(): help='Skips execution of the test cases of particular package and ' 'sub-packages' ) - parser.add_argument('--coverage', nargs='?', const=True, type=bool, - default=False, help='Enable code coverage feature') parser.add_argument( '--default_browser', help='Executes the feature test in specific browser' @@ -776,11 +771,6 @@ if __name__ == '__main__': if args['pkg'] is not None: node_name = args['pkg'].split('.')[-1] - # Start coverage - if test_utils.is_coverage_enabled(args): - cov = coverage.Coverage(config_file=COVERAGE_CONFIG_FILE) - cov.start() - # Check if feature tests included & parallel tests switch passed if test_utils.is_feature_test_included(args) and \ test_utils.is_parallel_ui_tests(args): @@ -887,15 +877,6 @@ if __name__ == '__main__': raise print_test_results() - # Stop code coverage - if test_utils.is_coverage_enabled(args): - cov.stop() - cov.save() - - # Print coverage only if coverage args given in command line - if test_utils.is_coverage_enabled(args): - test_utils.print_and_store_coverage_report(cov) - print("Please check output in file: %s/regression.log\n" % CURRENT_PATH) # Unset environment variable