Add support for generating tests by comment
Writing tests can be time consuming and may also not be very accessible or very easy to understand for everyone.
Something like
Advantages
- Everything in 1 file (code, unit test & documentation)
- Structured way of commenting
- Potentially it could even generate an interactive playground for documentation/manual testing
Disadvantages
- Perhaps not suitable for more complex unit tests
Inspired by
https://github.com/aaron-bond/better-comments
Please upvote if you like this idea. I think it should be very do-able.
It would also be nice to have a test-generator utility, eg. something similar to what Jest or Playwright have: create scaffolding for the current function, class, module so I don't have to write everything from scratch. It should be easily template-able. In Visual Studio (not Code) you can right click when in the method and just say "Create Unit Test" which will create the test file for you and do a basic template. Saves a lot of time and helps code/test maintenance as everything is done in a consistent way.
I know the status is discussion but it already received 6 upvotes so it would at least make 6 people happy😉
Are there plans for supporting this? Any thoughts about the matter?
Good thing that you mentioned that. No, we are not planning to introduce any comment parsing feature in core: https://github.com/vitest-dev/vitest/issues/3035#issuecomment-2051246359