我有一种情况需要使用@font-face {
font-family: "Colfax", Arial, sans-serif;
src: url('/sfsites/c/resource/ColfaxRegular/Colfax-Regular.otf') format('otf');
}
@font-face {
font-family: "Colfax-Medium", Arial, sans-serif;
src: url('/sfsites/c/resource/ColfaxMedium/Colfax-Medium.otf') format('otf');
}
body, .profileName, .uiMenuItem a, .uiOutputText {
font-family: "Colfax", Arial, sans-serif;
}
.forceCommunityGlobalNavigation *, .forceCommunityGlobalNavigation button, .forceCommunityGlobalNavigation button:focus, .forceCommunityGlobalNavigation button[disabled], .forceCommunityGlobalNavigation button:hover, .forceCommunityGlobalNavigation a:focus, .forceCommunityGlobalNavigation a:hover {
font-family: "Colfax", Arial, sans-serif;
}
.forceCommunityGlobalNavigation .slds-list__item a, .forceCommunityGlobalNavigation .slds-list__item button, .uiButton {
font-family: "Colfax", Arial, sans-serif !important;
}
.forceCommunityHeadline .headlineTitleText {
font-family: "Colfax", Arial, sans-serif;
}
和TestNg
进行测试。我有这些示例类来说明这种情况。
JMockit
在服务类中,我需要注入public class Service {
private Dao dao;
public String fetch() {
List<String> items = new ArrayList<>();
ResultIterator iterator = dao.fetch();
while (iterator.hasNext()) {
String string = iterator.next();
items.add(string);
}
return String.join(", ", items);
}
}
依赖项。
Dao
public class Dao {
public ResultIterator fetch() {
List<String> data = new ArrayList<>(Arrays.asList("A", "B", "C", "D"));
return new ResultIterator(data);
}
}
类从后端获取数据,并提供Dao
类的实例。
ResultIterator
运行测试用例
public class ResultIterator implements Iterator<String> {
private int index = 0;
private List<String> data;
public ResultIterator(List<String> data) {
this.data = data;
}
@Override
public boolean hasNext() {
return index < data.size();
}
@Override
public String next() {
String res = data.get(index);
index++;
return res;
}
}
运行测试用例时,出现错误public class NGTest {
@Tested(fullyInitialized = true)
Service service;
@Injectable
Dao dao;
@Test
public void testFetchedData() throws Exception {
List<String> data = new ArrayList<>(Arrays.asList("E", "F", "G", "H"));
new Expectations() {
{
dao.fetch();
result = new ResultIterator(data);
}
};
String out = service.fetch();
System.out.println(out);
}
}
。在这里,我真的不想模拟迭代器。我只想将其传递给期望区。我正在使用java.lang.IllegalArgumentException: java.util.Iterator is not mockable
和TestNg 6.8