我正在寻找使用 Java 或 C# 代码进行集成测试的好示例
有无数的单元测试示例,但是您可以在此处提供,或者提供一个指向集成测试的好示例的链接,而不仅仅是一个比喻吗?我更喜欢 JUnit 示例,但这不一定是必需的。
There are untold number of unit test examples, but can you provide here, or provide a link to a good example of an integration test that isn't just a metaphor? I prefer a JUnit example, but that isn't necessarily a requirement.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
提供集成测试的示例并不是很有用。集成测试是一起测试多个组件以查看它们是否按预期一起工作的测试。
想象一下,您已经编写了一个词法分析器和一个解析器,并且想知道它们是否可以正常工作。您可以这样做:
编辑:
就我个人而言,我更喜欢区分快速测试和慢速测试。如果我单独或一起测试某些组件,那并不重要(至少对我来说)……重要的是,我的测试速度很快。当然,如果我同时测试许多组件,测试速度并不快。这取决于您尝试通过测试实现的目标(我使用它们在开发之前/期间编写测试以及作为回归套件......我不[必须]使用它们来表明我的实现与需求文档或其他内容相匹配像这样)。
Providing an example of an integration test is not soooo useful. A integration test is a test that tests multiple components together to see if they work together as expected.
Imagine you have written a lexer and a parser and would like to know if the work together properly. You might do it like this:
Edit:
Personally I prefer to distinguish between fast and slow tests. It doesn't matter that much (at least for me) if I do test some components in isolation or together ... what matters is, that my tests are fast. If I test to many components together the tests are not fast, of course. This depends of what you try to achieve with the tests (I use them for writing tests before/during development and as regression suite ... I don't [have to] use them to show that my implementation matches a requirement document or something like that).