Organize tests by type and function - #99
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the repository’s test organization so module paths reflect the production type and the function/method under test, improving cargo test output readability and test ownership clarity without intending to change runtime behavior.
Changes:
- Re-names and re-nests unit tests into
tests -> <type> -> <function/method>module hierarchies across crates. - Renames behavior-ambiguous test functions (e.g.,
test,test_*) to behavior-oriented names. - Documents the test-organization convention in
AGENTS.md.
Reviewed changes
Copilot reviewed 47 out of 47 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| promkit/src/terminal_session.rs | Reorganizes TerminalSession tests into nested modules by method/behavior. |
| promkit-widgets/tests/yamlz/multi_documents.rs | Renames YAML integration test to behavior-oriented name. |
| promkit-widgets/tests/jsonz/up.rs | Renames JSON navigation test to behavior-oriented name. |
| promkit-widgets/tests/jsonz/toggle.rs | Renames JSON toggle tests to behavior-oriented names. |
| promkit-widgets/tests/jsonz/tail.rs | Renames tail/JSONL tests to behavior-oriented names. |
| promkit-widgets/tests/jsonz/set_rows_visibility.rs | Renames visibility test to behavior-oriented name. |
| promkit-widgets/tests/jsonz/render_pretty.rs | Renames pretty-render test to behavior-oriented name. |
| promkit-widgets/tests/jsonz/multi_documents.rs | Renames multi-document tests to behavior-oriented names. |
| promkit-widgets/tests/jsonz/head.rs | Renames head/JSONL tests to behavior-oriented names. |
| promkit-widgets/tests/jsonz/get_all_paths.rs | Renames path-extraction tests to behavior-oriented names. |
| promkit-widgets/tests/jsonz/extract.rs | Renames extraction tests to behavior-oriented names. |
| promkit-widgets/tests/jsonz/down.rs | Renames JSON navigation tests to behavior-oriented names. |
| promkit-widgets/tests/jsonz/create_rows.rs | Renames row-creation tests to behavior-oriented names. |
| promkit-widgets/src/text/text.rs | Restructures Text tests into per-method modules and splits navigation coverage. |
| promkit-widgets/src/text/config.rs | Renames serde test module/test to behavior-oriented names. |
| promkit-widgets/src/text.rs | Restructures State::hit_at tests into tests -> state -> hit_at. |
| promkit-widgets/src/text_editor/text_editor.rs | Large re-org of TextEditor tests into nested per-method modules with clearer names. |
| promkit-widgets/src/text_editor/history.rs | Splits history navigation tests into backward/forward modules with clearer names. |
| promkit-widgets/src/text_editor/config.rs | Renames serde test module/test to behavior-oriented names. |
| promkit-widgets/src/text_editor.rs | Restructures State::hit_at tests into nested modules by method. |
| promkit-widgets/src/table.rs | Restructures Document and State tests into nested modules by type/method. |
| promkit-widgets/src/structured/yaml/document.rs | Reorganizes YAML document parsing tests into from_str / from_reader modules. |
| promkit-widgets/src/structured/yaml/config.rs | Wraps config tests under config and nests render_terminal_rows. |
| promkit-widgets/src/structured/yaml.rs | Reorganizes YAML widget State tests into nested modules by method. |
| promkit-widgets/src/structured/tree/treez.rs | Reorganizes tree adapter/row-op tests into nested modules by behavior. |
| promkit-widgets/src/structured/tree/config.rs | Renames serde test module/test to behavior-oriented names. |
| promkit-widgets/src/structured/tree.rs | Reorganizes tree widget State tests into nested modules by method. |
| promkit-widgets/src/structured/json/document.rs | Reorganizes JSON document parsing tests into from_str / from_reader modules. |
| promkit-widgets/src/structured/json/config.rs | Reorganizes config tests into config modules; renames serde tests for clarity. |
| promkit-widgets/src/structured/json.rs | Reorganizes JSON widget State tests into nested modules by method. |
| promkit-widgets/src/prefix_search/prefix_search.rs | Splits PrefixSearch tests by method (search, backward, forward, etc.). |
| promkit-widgets/src/prefix_search/config.rs | Renames serde test module/test to behavior-oriented names. |
| promkit-widgets/src/prefix_search.rs | Reorganizes State::create_graphemes tests into nested modules. |
| promkit-widgets/src/listbox/listbox.rs | Splits Listbox tests by method with behavior-oriented names. |
| promkit-widgets/src/listbox/config.rs | Renames serde test module/test to behavior-oriented names. |
| promkit-widgets/src/listbox.rs | Reorganizes State::hit_at tests into nested modules. |
| promkit-widgets/src/checkbox/config.rs | Renames serde test module/test to behavior-oriented names. |
| promkit-widgets/src/checkbox/checkbox.rs | Reorganizes checkbox tests into per-method modules; renames generic test names. |
| promkit-widgets/src/checkbox.rs | Reorganizes State::hit_at tests into nested modules. |
| promkit-core/src/widget.rs | Reorganizes WidgetViewport tests into nested modules by method. |
| promkit-core/src/terminal.rs | Reorganizes Terminal tests into nested modules by type/method. |
| promkit-core/src/render/layout.rs | Reorganizes layout tests into nested modules by function/type. |
| promkit-core/src/render.rs | Reorganizes renderer hit-test test into nested module. |
| promkit-core/src/grapheme.rs | Renames/restructures StyledGraphemes tests into nested modules with clearer names. |
| examples/repl/src/repl.rs | Reorganizes repl example tests into nested modules by function/behavior. |
| examples/csv/src/csv.rs | Reorganizes csv example tests into nested modules by type/function. |
| AGENTS.md | Documents the test-organization convention and example structure. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
171
to
+175
| mod tests { | ||
| use super::*; | ||
|
|
||
| fn rows(count: usize) -> Vec<Vec<StyledGraphemes>> { | ||
| vec![ | ||
| (0..count) | ||
| .map(|index| StyledGraphemes::from(format!("row {index}"))) | ||
| .collect(), | ||
| ] | ||
| } | ||
|
|
||
| fn command_bytes(command: impl crate::crossterm::Command) -> Vec<u8> { | ||
| let mut output = Vec::new(); | ||
| crossterm::queue!(output, command).unwrap(); | ||
| output | ||
| } | ||
|
|
||
| fn command_offset(output: &[u8], command: impl crate::crossterm::Command) -> usize { | ||
| let command = command_bytes(command); | ||
| output | ||
| .windows(command.len()) | ||
| .position(|window| window == command) | ||
| .expect("expected terminal command was not emitted") | ||
| } | ||
| mod terminal { | ||
| use super::*; |
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.
Summary
Reorganize tests so their module paths reflect the production type and function or method under test.
teststest/test_*cases to describe the expected behaviorAGENTS.mdThis makes test ownership clearer and produces more descriptive paths in
cargo testoutput.Scope
This is a test-organization refactor. No production API or runtime behavior changes are intended.
Verification
cargo fmt --all -- --checkcargo clippycargo test -- --nocapture --format pretty