<p>I have started working on a concurrent lazy <a href="https://github.com/gaigepr/lazylist" rel="nofollow">list recently</a> and was wondering if anyone had any tips or resources they can suggest for writing good tests for concurrent data structures. Thanks!</p>
<hr/>**评论:**<br/><br/>NovaX: <pre><p>There aren't too many insightful answers beyond the obvious ones. Generally you have to write non-concurrent tests, a few focused multi-threaded tests, and then bash it for good measure.</p>
<p>The techniques you might end up using are,</p>
<ul>
<li>parameterized tests</li>
<li>aspect-oriented validation</li>
<li>property-based testing</li>
<li>manual thread coordination</li>
<li>manually tweaking internals to mimic a state condition</li>
<li>static analyzers</li>
<li>mutation testing</li>
<li>short-running thread bashing to detect corruption</li>
<li>long-running thread bashing to detect rare scenarios</li>
<li>benchmarks & profilers (manual assurance of assumptions)</li>
</ul>
<p>You can see a lot of these used in my <a href="https://github.com/ben-manes/caffeine" rel="nofollow">Java caching library</a>.</p>
<ul>
<li>TestNG provides the <a href="https://github.com/ben-manes/caffeine/wiki/Contribute#parameterized-testing" rel="nofollow">hooks</a> for parameterizing and validating tests</li>
<li><a href="https://github.com/jayway/awaitility" rel="nofollow">Awaitility</a> is a very nice abstraction to the manual idioms (like using <code>CountDownLatch</code>) that it replaced.</li>
<li>I was able to forgo property testing because Guava's testlib does the same in a less random but exhaustive fashion.</li>
<li>I also did not use <a href="http://pitest.org" rel="nofollow">mutation testing</a> as the thread bashing covers a similar goal.</li>
<li>I also borrowed test suites when possible, such as TCKs, to identify scenarios and different expectations than my own of a common interface spec.</li>
</ul></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传