tdd - Hamcrest:file1 或者 file2 存在
问题描述
我目前将我的测试从 AsserJ 重构为 hamcrest 库。但是有一种说法是我不能迁移到 hamcrest。
tmp1 和 tmp2 在文件系统中包含两个路径。我需要验证 tmp1 或 tmp2 是否存在,但不能同时存在。当前的断言是
assertTrue(new File(tmp1).exists() ^ new File(tmp2).exists());
什么是等效的 hamcrest 测试?
解决方案
assertThat(new File(tmp1).exists() ^ new File(tmp2).exists(), is(true));
推荐阅读
- python - Backtrader / Python ValueError:x 年超出范围
- currency - 任何帮助或想法表示赞赏,左加入计算 DAX POWER BI
- python - 在 Python 中,我不明白切片操作的操作顺序 [-1:1:-1]
- javascript - 如何隐藏标题 React Navigation v.6.x 中的阴影?
- mysql - 将 COUNT 与 GROUP BY 和 FIELD 一起使用,计算值不存在的行
- html - Flexbox:具有不同对齐方式的列
- parsing - x86 32 位汇编解析器 | 逻辑问题
- ansible - Ansible 条件使用
- javascript - Javacript for loop 等待函数完成?
- javascript - 玩笑测试 onClick 的 util 功能