[DRAFT] UnitTest based tests#7906
Open
cjen1-msft wants to merge 6 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR proposes an initial integration of Python’s unittest framework into CCF’s end-to-end (e2e) test infrastructure by introducing a NetworkTestCase base class and a CMake/JSON-driven configuration mechanism, plus wiring a new ctest entry to run unittest discovery.
Changes:
- Add
NetworkTestCase(unittest.TestCase) that starts a CCF network once per test class and records failures to skip subsequent tests in the same class. - Add
CCF_TEST_CONFIG-driven JSON defaults loading ine2e_args.cli_args(), and generate a build-timetest_config.jsonvia CMake. - Add a new
e2e_unittestsctest target runningpython -m unittest discover, and add a first example test filetests/test_e2e_operations.py.
Custom instructions used:
.github/copilot-instructions.md.github/instructions/reviewing.instructions.md
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_e2e_operations.py | Adds first unittest-based wrapper class for existing e2e_operations tests |
| tests/infra/network.py | Introduces NetworkTestCase to run e2e tests under unittest |
| tests/infra/e2e_args.py | Loads config defaults from CCF_TEST_CONFIG / test_config.json, adds argv override |
| python/src/ccf/ledger.py | Fixes file handle lifetime in SimpleBuffer.from_file |
| CMakeLists.txt | Generates test_config.json, adds e2e_unittests ctest entry, refactors constitution args list |
| cmake/test_config.json.in | New template for JSON test configuration |
| cmake/common.cmake | Removes duplicated NODE_TICK_MS selection (now set in top-level CMake) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Several changes to make this work:
The atom in UnitTest is a TestCase.
So here I've mapped the suite to a single TestCase.
If down the line we still want to separate out different tests to different runners, we can do so by adding them to suites.
Selectors for single tests work:
I'm enthuastically open to suggestions and bikeshedding on this as it will be quite a large change and we need to ensure we are careful and correct in how we do it.
There is none of the reworks to the config, or deduplication or concurrent runners or anything like that, this is solely focused on showing how we could go about using unittest to improve the UX and improve the UX of our testing.
It does however pave the way to future improvements such as: