Java源码示例:ru.yandex.qatools.allure.annotations.Description
示例1
private Description getDescriptionAnnotation(final String description) {
return new Description() {
@Override
public String value() {
return description;
}
@Override
public DescriptionType type() {
return DescriptionType.TEXT;
}
@Override
public Class<? extends Annotation> annotationType() {
return Description.class;
}
};
}
示例2
public void updateDescription(final TestResult result) {
final Method method = getMethod();
if (method.isAnnotationPresent(Description.class)) {
final Description description = method.getAnnotation(Description.class);
if (description.type().equals(DescriptionType.HTML)) {
result.setDescriptionHtml(description.value());
} else {
result.setDescription(description.value());
}
}
}
示例3
@Title("testcase")
@Description("testcase description")
@Issue("ISSUE-2")
@Issues(@Issue("ISSUE-22"))
@TestCaseId("TEST-1")
@Stories("story2")
@Features("feature2")
@Severity(SeverityLevel.CRITICAL)
@org.testng.annotations.Test
public void testSomething() {
parameterWithoutName = "testValue1";
parameterWithName = "testValue2";
}
示例4
@Title("testcase")
@Description("testcase description")
@Issue("ISSUE-2")
@Issues(@Issue("ISSUE-22"))
@TestCaseId("TEST-1")
@Stories("story2")
@Features("feature2")
@Severity(SeverityLevel.CRITICAL)
@org.junit.Test
public void testSomething() {
parameterWithoutName = "testValue1";
parameterWithName = "testValue2";
}
示例5
/**
* Set default values for annotations.
* Initial annotation take precedence over the default annotation when both annotation types are present
*
* @param defaultAnnotations default value for annotations
*/
public void setDefaults(Annotation[] defaultAnnotations) {
if (defaultAnnotations == null) {
return;
}
for (Annotation each : defaultAnnotations) {
Class<? extends Annotation> key = each.annotationType();
if (Title.class.equals(key) || Description.class.equals(key)) {
continue;
}
if (!annotations.containsKey(key)) {
annotations.put(key, each);
}
}
}
示例6
/**
* Find first {@link ru.yandex.qatools.allure.annotations.Description} annotation
*
* @return {@link ru.yandex.qatools.allure.model.Description} or null if
* annotation doesn't present
*/
public ru.yandex.qatools.allure.model.Description getDescription() {
Description description = getAnnotation(Description.class);
return description == null ? null : new ru.yandex.qatools.allure.model.Description()
.withValue(description.value())
.withType(description.type());
}
示例7
/**
* @return true if {@link ru.yandex.qatools.allure.annotations.Description}
* annotation present in {@link #annotations} and false otherwise
*/
public boolean isDescriptionAnnotationPresent() {
return isAnnotationPresent(Description.class);
}