Hamcrest:file1或file2存在

时间:2018-08-25 12:15:47

标签: tdd hamcrest

我目前将测试从AsserJ重构到hamcrest库。但是有一个断言,我不能迁移到hamcrest。

tmp1和tmp2在文件系统中包含两个路径。我需要验证tmp1或tmp2是否存在,但不能同时存在。当前的断言是

assertTrue(new File(tmp1).exists() ^ new File(tmp2).exists());

什么是等强度的hamcrest测试?

1 个答案:

答案 0 :(得分:1)

 assertThat(new File(tmp1).exists() ^ new File(tmp2).exists(), is(true));
相关问题