本文整理匯總了Java中org.junit.runner.Description.createSuiteDescription方法的典型用法代碼示例。如果您正苦於以下問題:Java Description.createSuiteDescription方法的具體用法?Java Description.createSuiteDescription怎麽用?Java Description.createSuiteDescription使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.junit.runner.Description
的用法示例。
在下文中一共展示了Description.createSuiteDescription方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: map
import org.junit.runner.Description; //導入方法依賴的package包/類
private void map(Description source, Description parent) {
for (Description child : source.getChildren()) {
Description mappedChild;
if (child.getMethodName() != null) {
mappedChild = Description.createSuiteDescription(String.format("%s [%s](%s)", child.getMethodName(), getDisplayName(), child.getClassName()));
parent.addChild(mappedChild);
if (!isTestEnabled(new TestDescriptionBackedTestDetails(source, child))) {
disabledTests.add(child);
} else {
enabledTests.add(child);
}
} else {
mappedChild = Description.createSuiteDescription(child.getClassName());
}
descriptionTranslations.put(child, mappedChild);
map(child, parent);
}
}
示例2: TrisotechTCKTestRunner
import org.junit.runner.Description; //導入方法依賴的package包/類
protected TrisotechTCKTestRunner(Properties properties, Class<TrisotechTCKTest> testClass, String category, String testId, String testCase,
File testCaseFile, File resultCSV) throws InitializationError {
super(testClass);
this.properties = properties;
this.category = category;
this.testId = testId;
this.testCase = testCase;
this.testCaseFile = testCaseFile;
this.resultCSV = resultCSV;
runnerDescription = Description.createSuiteDescription(category + " - " + testCase);
try {
TestCases tcs = TckMarshallingHelper.load(new FileInputStream(testCaseFile));
modelName = tcs.getModelName();
for (TestCase tc : tcs.getTestCase()) {
Description testDescription = Description.createTestDescription(testClass, testCase + " - " + tc.getId());
TrisotechTCKTest myTest = testClass.newInstance();
myTest.setId(tc.getId());
myTest.setDescription(testDescription);
testCases.add(myTest);
runnerDescription.addChild(testDescription);
}
} catch (FileNotFoundException | JAXBException | InstantiationException | IllegalAccessException e) {
throw new InitializationError(e);
}
}
示例3: initDescription
import org.junit.runner.Description; //導入方法依賴的package包/類
private void initDescription() {
initExecutions();
if (description == null) {
description = Description.createSuiteDescription(target);
for (Execution execution : executions) {
execution.addDescriptions(description);
}
}
}
示例4: getSuiteUid
import org.junit.runner.Description; //導入方法依賴的package包/類
public String getSuiteUid(Description description) {
String suiteName = getSuiteName(description);
if (!getSuites().containsKey(suiteName)) {
Description suiteDescription = Description.createSuiteDescription(description.getTestClass());
testSuiteStarted(suiteDescription);
}
return getSuites().get(suiteName);
}
示例5: testCustomLevelPerMethod
import org.junit.runner.Description; //導入方法依賴的package包/類
public void testCustomLevelPerMethod() throws Exception {
LoggingListener loggingListener = new LoggingListener();
Description suiteDescription = Description.createSuiteDescription(TestClass.class);
Logger xyzLogger = Loggers.getLogger("xyz");
Logger abcLogger = Loggers.getLogger("abc");
final Level level = ESLoggerFactory.getRootLogger().getLevel();
assertThat(xyzLogger.getLevel(), equalTo(level));
assertThat(abcLogger.getLevel(), equalTo(level));
loggingListener.testRunStarted(suiteDescription);
assertThat(xyzLogger.getLevel(), equalTo(level));
assertThat(abcLogger.getLevel(), equalTo(level));
Method method = TestClass.class.getMethod("annotatedTestMethod");
TestLogging annotation = method.getAnnotation(TestLogging.class);
Description testDescription = Description.createTestDescription(LoggingListenerTests.class, "annotatedTestMethod", annotation);
loggingListener.testStarted(testDescription);
assertThat(xyzLogger.getLevel(), equalTo(Level.TRACE));
assertThat(abcLogger.getLevel(), equalTo(level));
loggingListener.testFinished(testDescription);
assertThat(xyzLogger.getLevel(), equalTo(level));
assertThat(abcLogger.getLevel(), equalTo(level));
loggingListener.testRunFinished(new Result());
assertThat(xyzLogger.getLevel(), equalTo(level));
assertThat(abcLogger.getLevel(), equalTo(level));
}
示例6: testInvalidClassTestLoggingAnnotation
import org.junit.runner.Description; //導入方法依賴的package包/類
public void testInvalidClassTestLoggingAnnotation() throws Exception {
final LoggingListener loggingListener = new LoggingListener();
final Description suiteDescription = Description.createSuiteDescription(InvalidClass.class);
final IllegalArgumentException e =
expectThrows(IllegalArgumentException.class, () -> loggingListener.testRunStarted(suiteDescription));
assertThat(e.getMessage(), equalTo("invalid test logging annotation [abc]"));
}
示例7: testInvalidMethodTestLoggingAnnotation
import org.junit.runner.Description; //導入方法依賴的package包/類
public void testInvalidMethodTestLoggingAnnotation() throws Exception {
final LoggingListener loggingListener = new LoggingListener();
final Description suiteDescription = Description.createSuiteDescription(InvalidMethod.class);
loggingListener.testRunStarted(suiteDescription);
final Method method = InvalidMethod.class.getMethod("invalidMethod");
final TestLogging annotation = method.getAnnotation(TestLogging.class);
Description testDescription = Description.createTestDescription(InvalidMethod.class, "invalidMethod", annotation);
final IllegalArgumentException e =
expectThrows(IllegalArgumentException.class, () -> loggingListener.testStarted(testDescription));
assertThat(e.getMessage(), equalTo("invalid test logging annotation [abc:INFO:WARN]"));
}
示例8: describeChild
import org.junit.runner.Description; //導入方法依賴的package包/類
@Override
protected Description describeChild(final FrameworkMethod method) {
final Spockito.Name name = Spockito.nameAnnotationOrNull(method.getMethod());
if (name != null && name.shortFormat()) {
return Description.createSuiteDescription(testName(method), method.getAnnotations());
} else {
return super.describeChild(method);
}
}
示例9: describeChild
import org.junit.runner.Description; //導入方法依賴的package包/類
@Override
protected Description describeChild(KarateFeature child) {
Description description = descriptions.get(child.getFeature().getPath());
if (description != null) {
return description;
}
Feature feature = child.getFeature().getGherkinFeature();
String name = feature.getKeyword() + ": " + feature.getName();
return Description.createSuiteDescription(name, feature);
}
示例10: CannotExecuteRunner
import org.junit.runner.Description; //導入方法依賴的package包/類
public CannotExecuteRunner(String displayName, Class<?> testClass, Throwable failure) {
description = Description.createSuiteDescription(String.format("%s(%s)", displayName, testClass.getName()));
this.failure = failure;
}
示例11: testCustomLevelPerClass
import org.junit.runner.Description; //導入方法依賴的package包/類
public void testCustomLevelPerClass() throws Exception {
LoggingListener loggingListener = new LoggingListener();
Description suiteDescription = Description.createSuiteDescription(AnnotatedTestClass.class);
Logger abcLogger = Loggers.getLogger("abc");
Logger xyzLogger = Loggers.getLogger("xyz");
// we include foo and foo.bar to maintain that logging levels are applied from the top of the hierarchy down; this ensures that
// setting the logging level for a parent logger and a child logger applies the parent level first and then the child as otherwise
// setting the parent level would overwrite the child level
Logger fooLogger = Loggers.getLogger("foo");
Logger fooBarLogger = Loggers.getLogger("foo.bar");
final Level level = ESLoggerFactory.getRootLogger().getLevel();
assertThat(xyzLogger.getLevel(), equalTo(level));
assertThat(abcLogger.getLevel(), equalTo(level));
assertThat(fooLogger.getLevel(), equalTo(level));
assertThat(fooBarLogger.getLevel(), equalTo(level));
loggingListener.testRunStarted(suiteDescription);
assertThat(xyzLogger.getLevel(), equalTo(level));
assertThat(abcLogger.getLevel(), equalTo(Level.WARN));
assertThat(fooLogger.getLevel(), equalTo(Level.WARN));
assertThat(fooBarLogger.getLevel(), equalTo(Level.ERROR));
Description testDescription = Description.createTestDescription(LoggingListenerTests.class, "test");
loggingListener.testStarted(testDescription);
assertThat(xyzLogger.getLevel(), equalTo(level));
assertThat(abcLogger.getLevel(), equalTo(Level.WARN));
assertThat(fooLogger.getLevel(), equalTo(Level.WARN));
assertThat(fooBarLogger.getLevel(), equalTo(Level.ERROR));
loggingListener.testFinished(testDescription);
assertThat(xyzLogger.getLevel(), equalTo(level));
assertThat(abcLogger.getLevel(), equalTo(Level.WARN));
assertThat(fooLogger.getLevel(), equalTo(Level.WARN));
assertThat(fooBarLogger.getLevel(), equalTo(Level.ERROR));
loggingListener.testRunFinished(new Result());
assertThat(xyzLogger.getLevel(), equalTo(level));
assertThat(abcLogger.getLevel(), equalTo(level));
assertThat(fooLogger.getLevel(), equalTo(level));
assertThat(fooBarLogger.getLevel(), equalTo(level));
}
示例12: testCustomLevelPerClassAndPerMethod
import org.junit.runner.Description; //導入方法依賴的package包/類
public void testCustomLevelPerClassAndPerMethod() throws Exception {
LoggingListener loggingListener = new LoggingListener();
Description suiteDescription = Description.createSuiteDescription(AnnotatedTestClass.class);
Logger abcLogger = Loggers.getLogger("abc");
Logger xyzLogger = Loggers.getLogger("xyz");
final Level level = ESLoggerFactory.getRootLogger().getLevel();
assertThat(xyzLogger.getLevel(), equalTo(level));
assertThat(abcLogger.getLevel(), equalTo(level));
loggingListener.testRunStarted(suiteDescription);
assertThat(xyzLogger.getLevel(), equalTo(level));
assertThat(abcLogger.getLevel(), equalTo(Level.WARN));
Method method = TestClass.class.getMethod("annotatedTestMethod");
TestLogging annotation = method.getAnnotation(TestLogging.class);
Description testDescription = Description.createTestDescription(LoggingListenerTests.class, "annotatedTestMethod", annotation);
loggingListener.testStarted(testDescription);
assertThat(xyzLogger.getLevel(), equalTo(Level.TRACE));
assertThat(abcLogger.getLevel(), equalTo(Level.WARN));
loggingListener.testFinished(testDescription);
assertThat(xyzLogger.getLevel(), equalTo(level));
assertThat(abcLogger.getLevel(), equalTo(Level.WARN));
Method method2 = TestClass.class.getMethod("annotatedTestMethod2");
TestLogging annotation2 = method2.getAnnotation(TestLogging.class);
Description testDescription2 = Description.createTestDescription(LoggingListenerTests.class, "annotatedTestMethod2", annotation2);
loggingListener.testStarted(testDescription2);
assertThat(xyzLogger.getLevel(), equalTo(Level.DEBUG));
assertThat(abcLogger.getLevel(), equalTo(Level.TRACE));
loggingListener.testFinished(testDescription2);
assertThat(xyzLogger.getLevel(), equalTo(level));
assertThat(abcLogger.getLevel(), equalTo(Level.WARN));
loggingListener.testRunFinished(new Result());
assertThat(xyzLogger.getLevel(), equalTo(level));
assertThat(abcLogger.getLevel(), equalTo(level));
}
示例13: getDescription
import org.junit.runner.Description; //導入方法依賴的package包/類
@Override
public Description getDescription() {
return Description.createSuiteDescription(testClass.getName(),
testClass.getJavaClass().getAnnotations());
}
示例14: getDescription
import org.junit.runner.Description; //導入方法依賴的package包/類
@Override
public Description getDescription() {
return Description.createSuiteDescription(testClass);
}