Skip to content

Commit

Permalink
test: enable running individual independent functional test methods
Browse files Browse the repository at this point in the history
- Some test methods in the functional test framework are independent
  and do not require any previous context or setup defined in `run_test`.
- This commit adds a new option for running these specific methods within a test file,
  allowing them to be executed individually without running the entire test suite.

- running test methods that require an argument or context will fail.
  • Loading branch information
ismaelsadeeq committed Nov 11, 2024
1 parent 0903ce8 commit 409d0d6
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion test/functional/test_framework/test_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ def main(self):

try:
self.setup()
self.run_test()
if self.options.test_methods:
self.run_test_methods()
else:
self.run_test()

except JSONRPCException:
self.log.exception("JSONRPC error")
self.success = TestStatus.FAILED
Expand All @@ -155,6 +159,13 @@ def main(self):
exit_code = self.shutdown()
sys.exit(exit_code)

def run_test_methods(self):
for method_name in self.options.test_methods:
self.log.info(f"Attempting to execute method: {method_name}")
method = getattr(self, method_name)
method()
self.log.info(f"Method '{method_name}' executed successfully.")

def parse_args(self, test_file):
previous_releases_path = os.getenv("PREVIOUS_RELEASES_DIR") or os.getcwd() + "/releases"
parser = argparse.ArgumentParser(usage="%(prog)s [options]")
Expand Down Expand Up @@ -194,6 +205,8 @@ def parse_args(self, test_file):
help="use BIP324 v2 connections between all nodes by default")
parser.add_argument("--v1transport", dest="v1transport", default=False, action="store_true",
help="Explicitly use v1 transport (can be used to overwrite global --v2transport option)")
parser.add_argument("--test_methods", dest="test_methods", nargs='*',
help="Run specified test methods sequentially instead of the full test. Use only for methods that do not depend on any context set up in run_test or other methods.")

self.add_options(parser)
# Running TestShell in a Jupyter notebook causes an additional -f argument
Expand Down

0 comments on commit 409d0d6

Please sign in to comment.