2017-05-05 106 views
0

我做了一個簡單的測試:Assertj提取和包含不匹配

Person p = new Person(); 
p.setFirstName("Stéphane"); 
p.setLastName("Traumat"); 

assertThat(p) 
.extracting("firstName", "lastName") 
.contains(tuple("Stéphane", "Traumat")); 

我也得到一個奇怪的結果:

java.lang.AssertionError: 
Expecting: 
<["Stéphane", "Traumat"]> 
to contain: 
<[("Stéphane", "Traumat")]> 
but could not find: 
<[("Stéphane", "Traumat")]> 

任何人都可以幫我嗎?

回答

2

不要使用元組,extracting在你的情況下的結果是一個簡單的數組,請看看javadoc的extracting,它包含一個示例來展示如何使用它。