Skip to content

Enable running a concrete test from a test file #523

Merged
Chemaclass merged 3 commits into
mainfrom
feat/496-run-concrete-test
Nov 29, 2025
Merged

Enable running a concrete test from a test file #523
Chemaclass merged 3 commits into
mainfrom
feat/496-run-concrete-test

Conversation

@Chemaclass
Copy link
Copy Markdown
Member

@Chemaclass Chemaclass commented Nov 29, 2025

📚 Description

Enable running a concrete test by specifying the function name or line number directly in the file path, similar to how other testing frameworks (like PHPUnit or pytest) allow targeting specific tests.

This feature adds two new syntaxes:

  • path::function_name - Filter tests by function name (supports partial matching)
  • path:line_number - Run the test function that contains the specified line

🎯 Usage Examples

Run a specific test by function name

./bashunit tests/unit/example_test.sh::test_my_function

Run tests matching a partial name

# Runs all tests containing "spy" in their name
./bashunit tests/unit/test_doubles_test.sh::test_spy

Run the test at a specific line number

# Useful when jumping to a test from your editor
./bashunit tests/unit/example_test.sh:42

Error handling for invalid line numbers

# Shows error if line is before any test function
./bashunit tests/unit/example_test.sh:1
# Error: No test function found at line 1 in tests/unit/example_test.sh

Traditional filter still works

./bashunit tests/unit/example_test.sh --filter test_my_function

🔖 Changes

  • Add helper::parse_file_path_filter() to extract filter from file path
  • Add helper::find_function_at_line() to resolve line numbers to test functions
  • Update main::cmd_test() to process inline filters from file paths
  • Add unit tests for the new helper functions
  • Add acceptance tests for end-to-end validation

🖼️ Doc

Screenshot 2025-11-29 at 18 18 23

✅ Checklist

  • I updated the CHANGELOG.md to reflect the new feature
  • Tests pass locally
  • Documentation updated

Closes #496

Add support for specifying test functions directly in the file path:
- `path::function_name` - filter by test function name
- `path:line_number` - run test containing the specified line

Closes #496
@Chemaclass Chemaclass added the enhancement New feature or request label Nov 29, 2025
@Chemaclass Chemaclass self-assigned this Nov 29, 2025
@TypedDevs TypedDevs deleted a comment from chatgpt-codex-connector Bot Nov 29, 2025
@Chemaclass Chemaclass changed the title Run concrete test Enable running a concrete test from a test file Nov 29, 2025
@Chemaclass Chemaclass merged commit 68eb45a into main Nov 29, 2025
15 checks passed
@Chemaclass Chemaclass deleted the feat/496-run-concrete-test branch November 29, 2025 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable running a concrete test from a test file

2 participants