是否有针对控制台java应用程序的通用集成测试框架?
例如,我要写一个应用程序。它的核心要求很简单。它不断扫描文件夹。如果有新文件到达,它会将其传输到 FTP 站点。它将用 JAVA 编写为控制台应用程序。
我想知道是否有针对此类应用程序的集成测试框架(例如开源框架)?它应该能够测试以下相同的测试用例。
- 生成文件,然后检查这些文件是否传输到FTP。
- 如果FTP宕机,应用程序能否报告相应的警告日志?
- 等等。
提前致谢。
For example, I am going to write an application. Its core requirement is simple. It keeps scanning a folder. If new files arrive, it will transfer it to a FTP site. It will be written in JAVA as a console application.
I am wondering if there is integration test framework, like open source one, for this kind of application? It should be capable of testing the following sameple test cases.
- Generate files, then check if these files are transferred to FTP.
- If FTP is down, can the application report corresponding warning logs?
- etc.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
JUnit 与一些模拟框架结合,例如 Mockito 应该能让你顺利一些。如果您想更进一步,例如运行外部服务的实际实例,您可以结合使用 JUnit,例如 Cargo 用于启动 Java EE 容器作为测试的一部分。像 HSQLDB 这样的轻量级内存数据库通常用作集成测试的占位符数据库。
我听说有些人使用 JBoss Arquillian,但我自己还没有尝试过。不过,它更多地用于 Java EE 组件的远程测试,因此可能不符合您的确切要求。
JUnit combined with some mocking framework, like Mockito should get you a fair bit on your way. If you want to take it further, for instance having actual instances running of external service, you can use JUnit combined with, for instance, Cargo to start up Java EE containers as part of your test. Light-weight, in-memory databases like HSQLDB is often used as placeholder databases for integration tests.
I've heard some people using JBoss Arquillian, but haven't tried it myself. It's more for remote testing of Java EE components though, so might not fit your exact requirement.