TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Feedback on project idea (automated regression test generation)

2 点作者 sysk超过 10 年前
I&#x27;ve noticed that when I write Javascript tests (and am in a rush), I often just call a bunch of functions with (semi-)randomly chosen arguments, check what return values &#x2F; changed state I get and codify that in a test suite using asserts so that when I want to refactor later I can catch some bugs. It&#x27;s obviously not the ideal way to write tests but it&#x27;s better than nothing.<p>I was wondering if I could automate the process by writing a tool that would extract all exported functions from a module, call them with randomly generated arguments and save return values and&#x2F;or changed state. The tool could then generate a test suite using that information. The tool could also be used to quickly add tests to third party libraries.<p>Of course this tool would generate &quot;dumb&quot; tests with raw data but the intent here is not to offer an alternative to human written tests but rather to offer an alternative to no tests at all.<p>The concept could be applied to other languages as well.<p>Does such a tool already exist?<p>Am I overlooking some critical issue?<p>Do you think such a tool would be useful?

1 comment

S4M超过 10 年前
There is something called quick_check.js [0] that looks similar to what you want. It&#x27;s inspired by Haskell&#x27;s QuickCheck library [1].<p>[0] <a href="https://github.com/gampleman/quick_check.js" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;gampleman&#x2F;quick_check.js</a><p>[1] <a href="https://wiki.haskell.org/Introduction_to_QuickCheck1" rel="nofollow">https:&#x2F;&#x2F;wiki.haskell.org&#x2F;Introduction_to_QuickCheck1</a>