本文整理汇总了Java中com.sandwich.koan.result.KoanMethodResult类的典型用法代码示例。如果您正苦于以下问题:Java KoanMethodResult类的具体用法?Java KoanMethodResult怎么用?Java KoanMethodResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KoanMethodResult类属于com.sandwich.koan.result包,在下文中一共展示了KoanMethodResult类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testToString
import com.sandwich.koan.result.KoanMethodResult; //导入依赖的package包/类
@Test
public void testToString() throws Exception {
KoanResultBuilder builder = new KoanResultBuilder()
.remainingCases(Arrays.asList(OneFailingKoan.class.getSimpleName()))
.methodResult(new KoanMethodResult(KoanMethod.getInstance("", OneFailingKoan.class.getDeclaredMethods()[0]), "msg", "2"))
.level("1")
.numberPassing(3);
KoanSuiteResult result = builder.build();
String string = result.toString();
assertTrue(string.contains("1"));
assertTrue(string.contains("2"));
assertTrue(string.contains("3"));
assertTrue(string.contains(OneFailingKoan.class.getSimpleName()));
assertTrue(string.contains(OneFailingKoan.class.getDeclaredMethods()[0].getName()));
assertTrue(string.contains("msg"));
}
示例2: runKoans
import com.sandwich.koan.result.KoanMethodResult; //导入依赖的package包/类
KoanSuiteResult runKoans() {
List<String> passingSuites = new ArrayList<String>();
List<String> failingSuites = new ArrayList<String>();
String level = null;
KoanMethodResult failure = null;
DynamicClassLoader loader = KoanClassLoader.getInstance();
Path pathToEnlightenment = getPathToEnlightenment();
KoanSuiteCompilationListener compilationListener = new KoanSuiteCompilationListener();
int successfull = 0;
for (Entry<String, Map<String, Map<String, KoanElementAttributes>>> packages : pathToEnlightenment) {
for (Entry<String, Map<String, KoanElementAttributes>> e : packages.getValue().entrySet()) {
String name = e.getKey().substring(e.getKey().lastIndexOf('.')+1);
if(failure == null){
Object suite = safelyConstructSuite(loader, compilationListener, e);
final List<KoanElementAttributes> attributes = new ArrayList<KoanElementAttributes>(e.getValue().values());
final List<KoanMethod> methods = mergeJavaFilesMethodsAndThoseInXml(suite, attributes, pathToEnlightenment.getOnlyMethodNameToRun());
Collections.sort(methods, new KoanComparator());
for (final KoanMethod koan : methods) {
KoanMethodResult result = KoanMethodRunner.run(suite, koan);
if(KoanMethodResult.PASSED != result){
// Test failed!
failure = result;
failingSuites.add(name);
break;
}else{
successfull++;
}
}
if (failure == null) {
passingSuites.add(name);
}
level = packages.getKey();
}else{
failingSuites.add(name);
}
}
}
return new KoanResultBuilder()
.level(level)
.numberPassing(successfull)
.totalNumberOfKoanMethods(pathToEnlightenment.getTotalNumberOfKoans())
.methodResult(failure).passingCases(passingSuites)
.remainingCases(failingSuites).build();
}