在过去,我为JUnit
编写了API, Services, functions.
测试用例
第一次我在使用Java ProcessBuilder
运行命令行实用工具时,我搞不懂如何编写测试用例。
例如,我正在编写鬼脚本来破解多个tiff文件中的PDF文件。
那么,我如何为这个案例编写测试用例呢?
发布于 2017-07-30 08:54:41
1. Invoke the script using Java ProcessBuilder. Let it read the known good PDF file and generate tiff files in a temporary directory.
2. Compare each generated tiff file with the known good ones.
发布于 2017-07-30 08:57:13
这取决于你要测试什么。对于单元测试,您需要对将要使用的API进行简单的抽象级别:测试您自己的逻辑,并验证API是通过模拟调用的(例如,Mockito)。
在集成测试中,您将测试整个代码,然后验证结果。在您的示例中,您可以传递一些已知的PDF,然后检查脚本生成的TIFF文件的存在和大小。
https://stackoverflow.com/questions/45398026
复制相似问题