Repository navigation
feat: add a code action that generates a test skeleton - #565
Merged
Merged
Conversation
This was referenced Oct 6, 2026
V has no test framework, so the file layout is the whole contract: `foo.v` is tested by `foo_test.v` beside it, and a test file holds only `test_` functions. Remembering that convention is a small tax on every new file. The code action creates the `_test.v` file with one `test_` function per public function in the source, each with a placeholder assertion to replace. It is offered on `.v` files only, and only when the source has public functions — a module with nothing public has nothing to test, and an empty test file is worse than no test file. It refuses to overwrite an existing test file, because that would discard work the user already wrote. The generation lives in a pure module so it can be tested without an editor. I confirmed the tests catch something by breaking the public-function regex and watching the generation test fail, then reverting. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
metif12
force-pushed
the
feat/generate-test-skeleton
branch
from
October 7, 2026 06:26
07952b3 to
49effc6
Compare
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.
What this adds
A code action that generates a test skeleton.
V has no test framework, so the file layout is the whole contract:
foo.vistested by
foo_test.vbeside it, and a test file holds onlytest_functions.Remembering that convention is a small tax on every new file.
On a
.vfile with public functions, V: Generate Test File creates the_test.vfile beside it with onetest_function per public function, each witha placeholder assertion to replace.
Design
.vfiles only, and only when the source has public functions. Amodule with nothing public has nothing to test, and an empty test file is worse
than no test file.
user already wrote.
Verification
npm run lint,npm run lint:md,npm run test:grammar,npm run buildandnpm run packageall pass.npm testreports 26 tests, 23 pass, 3 fail. The three failures are thepre-existing Windows path-separator tests on
master, fixed in#561 and not touched here.
Proof the new tests catch something. I broke the public-function regex in
testSkeleton.tsand watchedgenerates one test function per public functiongo red, then reverted it.
Known limitations
creation are not covered by the extension-host suite; the generation logic is.
assert true, which always passes. The userreplaces it with a real assertion. A generated test that passes is not
evidence that it tests anything.
pub fndeclarations are found. A public function inside astructor apub fnwith a receiver is not matched, because the regex isanchored to column zero and V has no nested function declarations.
Relation to other PRs
Independent of #556, #557, #558, #559, #560, #561, #562, #563 and #564. It adds
new files and touches
extension.tsandpackage.jsononly where the other PRsdo not.