本文整理了Java中org.testng.annotations.Test.expectedExceptions()
方法的一些代码示例,展示了Test.expectedExceptions()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Test.expectedExceptions()
方法的具体详情如下:
包路径:org.testng.annotations.Test
类名称:Test
方法名:expectedExceptions
暂无
代码示例来源:origin: selenide/selenide
boolean shouldIntercept(Method testMethod) {
if (testMethod == null) return false;
Test annotation = testMethod.getAnnotation(Test.class);
return annotation != null && asList(annotation.expectedExceptions()).isEmpty();
}
代码示例来源:origin: org.testng/testng
result.setDescription(
findInherited(test.description(), cls, Test.class, "description", DEFAULT_STRING));
result.setExpectedExceptions(test.expectedExceptions());
result.setExpectedExceptionsMessageRegExp(test.expectedExceptionsMessageRegExp());
result.setSuiteName(test.suiteName());
代码示例来源:origin: cbeust/testng
result.setDescription(
findInherited(test.description(), cls, Test.class, "description", DEFAULT_STRING));
result.setExpectedExceptions(test.expectedExceptions());
result.setExpectedExceptionsMessageRegExp(test.expectedExceptionsMessageRegExp());
result.setSuiteName(test.suiteName());
代码示例来源:origin: jmockit/jmockit1
private static boolean isExpectedException(@Nonnull IInvokedMethod invokedMethod, @Nonnull Throwable thrownByTest) {
Method testMethod = invokedMethod.getTestMethod().getConstructorOrMethod().getMethod();
Class<?>[] expectedExceptions = testMethod.getAnnotation(Test.class).expectedExceptions();
Class<? extends Throwable> thrownExceptionType = thrownByTest.getClass();
for (Class<?> expectedException : expectedExceptions) {
if (expectedException.isAssignableFrom(thrownExceptionType)) {
return true;
}
}
return false;
}
代码示例来源:origin: org.powermock/powermock-module-testng
public String[] getPackagesToIgnore(AnnotatedElement element) {
List<String> ignoredPackages = new LinkedList<String>();
if (element instanceof Class<?>) {
Class<?> klazz = (Class<?>) element;
for (Method method : klazz.getMethods()) {
Test annotation = method.getAnnotation(Test.class);
if (annotation != null) {
Class<?>[] ignores = annotation.expectedExceptions();
if (ignores != null) {
for (Class<?> ignorePackage : ignores) {
ignoredPackages.add(ignorePackage.getName());
}
}
}
}
Class<?> superclass = klazz.getSuperclass();
if (superclass != null && !superclass.equals(Object.class)) {
String[] packagesToIgnore = getPackagesToIgnore(superclass);
ignoredPackages.addAll(Arrays.asList(packagesToIgnore));
}
}
return ignoredPackages.toArray(new String[ignoredPackages.size()]);
}
}
内容来源于网络,如有侵权,请联系作者删除!