Map Tests to Code with vg tests
vg tests maps tests to a node via call or coverage linkage, finds untested nodes nearby with --missing, and prints or runs the minimal test command with --run or --exec.
Knowing which tests exercise a given piece of code lets you run the right tests instead of the whole suite. vg tests maps tests to a node via call or coverage linkage, finds gaps, and can run exactly the tests that matter.
Prerequisites
- A built code graph from
vg build - A test suite in the repository
Steps
1. Build the graph
vg build
2. List tests for a node
vg tests
vg tests shows which tests cover the node via call or coverage linkage.
3. Find untested nodes
Surface nearby code that has no test coverage:
vg tests --missing
--missing highlights untested nodes near the one you queried — your coverage gaps.
4. Print the minimal command
Get the minimal command to exercise exactly the relevant tests:
vg tests --run
--run prints the command so you can review it before running.
5. Execute the minimal tests
Run those tests directly:
vg tests --exec
--exec runs the minimal command, exercising only the tests tied to the node.
Verification
Confirm vg tests lists covering tests for the node, that --missing surfaces gaps, and that --run prints a command which --exec executes successfully.
Next Steps
- Combine with
vg impact --testsbefore shipping - Find central, must-test nodes with
vg hubs - Explain a node with
vg show