下面列出了org.junit.Ignore#value ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private static void prepareIgnoreMessage(Description description, boolean commentMessage) {
Map attrs = new HashMap();
if (commentMessage) {
try {
final Ignore ignoredAnnotation = (Ignore)description.getAnnotation(Ignore.class);
if (ignoredAnnotation != null) {
final String val = ignoredAnnotation.value();
if (val != null) {
attrs.put("message", val);
}
}
}
catch (NoSuchMethodError ignored) {
//junit < 4.4
}
}
attrs.put("name", getMethodName(description));
System.out.println(ServiceMessage.asString(ServiceMessageTypes.TEST_IGNORED, attrs));
}
/**
*
* @see org.junit.runner.notification.RunListener#testIgnored(org.junit.runner.Description)
*/
@Override
public void testIgnored( Description description ) throws Exception {
if (!ActiveDbAppender.isAttached) {
return;
}
if (log.isDebugEnabled()) {
log.info("testIgnored(): description: " + description.getDisplayName() + "| is test: "
+ description.isTest() + "| test class: " + description.getClassName()
+ "| test method: " + description.getMethodName() + "| children: 0? =>"
+ description.getChildren());
}
// manually invoking testStarted()
testStarted(description);
String ignoreDetails = "";
Ignore ignoreAnnotation = getMethod(description).getAnnotation(Ignore.class);
if (ignoreAnnotation != null) {
ignoreDetails = ignoreAnnotation.value();
}
if (ignoreDetails.isEmpty()) {
logger.info(MSG__TEST_IGNORED);
} else {
logger.info(MSG__TEST_IGNORED + " Details: " + ignoreDetails);
}
//open a performance test scenario and test case
logger.endTestcase(TestCaseResult.SKIPPED);
sendTestEndEventToAgents();
super.testIgnored(description);
}
public String
getIgnoredMessage(Description description) {
Ignore ignore = description.getAnnotation(Ignore.class
);
return ignore
== null || ignore.value()
.isEmpty() ? "Test ignored (without reason)!" : ignore.value();
}
public String getIgnoredMessage(Description description) {
Ignore ignore = description.getAnnotation(Ignore.class);
return ignore == null || ignore.value().isEmpty() ? "Test ignored (without reason)!" : ignore.value();
}
private StatusDetails getIgnoredMessage(final Description description) {
final Ignore ignore = description.getAnnotation(Ignore.class);
final String message = Objects.nonNull(ignore) && !ignore.value().isEmpty()
? ignore.value() : "Test ignored (without reason)!";
return new StatusDetails().setMessage(message);
}
public String getIgnoredMessage(Description description) {
Ignore ignore = description.getAnnotation(Ignore.class);
return ignore == null || ignore.value().isEmpty() ? "Test ignored (without reason)!" : ignore.value();
}