當前位置: 首頁>>代碼示例>>Java>>正文


Java Description.createTestDescription方法代碼示例

本文整理匯總了Java中org.junit.runner.Description.createTestDescription方法的典型用法代碼示例。如果您正苦於以下問題:Java Description.createTestDescription方法的具體用法?Java Description.createTestDescription怎麽用?Java Description.createTestDescription使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.junit.runner.Description的用法示例。


在下文中一共展示了Description.createTestDescription方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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);
    }

}
 
開發者ID:dmn-tck,項目名稱:tck,代碼行數:27,代碼來源:TrisotechTCKTestRunner.java

示例2: shouldRun

import org.junit.runner.Description; //導入方法依賴的package包/類
@Override
public boolean shouldRun(final Description description) {
    if (description.isTest()) {
        return delegate.shouldRun(description);
    }

    // explicitly check if any children want to run
    for (Description child : description.getChildren()) {
        if (shouldRun(child)) {
            return true;
        }
        //Intellij bug, we get the wrong description, let us test with a slightly modified one now
        final Description relaxed = Description.createTestDescription(
                child.getTestClass(), getMethodName(child.getDisplayName())
        );
        if (shouldRun(relaxed)) {
            return true;
        }
    }
    return false;
}
 
開發者ID:tools4j,項目名稱:spockito,代碼行數:22,代碼來源:MethodLevelFilter.java

示例3: reportHelperWillComplainIfMoreThanOneIsActive

import org.junit.runner.Description; //導入方法依賴的package包/類
@Test
public void reportHelperWillComplainIfMoreThanOneIsActive() {
    TestableEventReporter eventReporter = new TestableEventReporter();
    Description description = Description.createTestDescription(this.getClass().getCanonicalName(), "name");
    ReportHelper firstHelper = new ReportHelper(eventReporter);
    ReportHelper nextHelper = new ReportHelper(eventReporter);

    firstHelper.starting(description);
    // Its ok to stop using a helper and use another one
    nextHelper.starting(description);
    // but we should fail if we ever use it again
    try {
        firstHelper.finished(description);
        fail("Expected an IllegalArgumentException because there is more than one reporter active");
    } catch (IllegalStateException e) {
        assertThat(e.getMessage(), containsString("@Rules"));
    }
}
 
開發者ID:Microsoft,項目名稱:AppCenter-Test-Espresso-Extensions,代碼行數:19,代碼來源:ReportHelperTest.java

示例4: testTestRunStartedSupportsClassInDefaultPackage

import org.junit.runner.Description; //導入方法依賴的package包/類
public void testTestRunStartedSupportsClassInDefaultPackage() throws Exception {
    LoggingListener loggingListener = new LoggingListener();
    Description description = Description.createTestDescription(Class.forName("Dummy"), "dummy");

    // Will throw an exception without the check for testClassPackage != null in testRunStarted
    loggingListener.testRunStarted(description);
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:8,代碼來源:LoggingListenerTests.java

示例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));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:32,代碼來源:LoggingListenerTests.java

示例6: 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]"));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:15,代碼來源:LoggingListenerTests.java

示例7: getMethodDescriptions

import org.junit.runner.Description; //導入方法依賴的package包/類
private List<Description> getMethodDescriptions(final Runner runner) {

        final String displayName = runner.getDescription().getDisplayName();
        final List<FrameworkMethod> methods = getTestClass().getAnnotatedMethods(Test.class);
        List<Description> descriptions = new ArrayList<Description>();
        for (FrameworkMethod method : methods) {
            final Description description = Description.createTestDescription(getTestClass().getJavaClass(), method.getName() + displayName, method.getAnnotations());
            descriptions.add(description);
        }

        return descriptions;
    }
 
開發者ID:stacs-srg,項目名稱:shabdiz,代碼行數:13,代碼來源:ExperimentRunner.java

示例8: testJSJVMBackendFrameworkMethod

import org.junit.runner.Description; //導入方法依賴的package包/類
private void testJSJVMBackendFrameworkMethod(FrameworkMethod aFrameworkMethod, RunNotifier aRunNotifier) {
    Description theDescription = Description.createTestDescription(testClass.getJavaClass(), aFrameworkMethod.getName() + " JVM Target");
    aRunNotifier.fireTestStarted(theDescription);
    try {
        // Simply invoke using reflection
        Object theInstance = testClass.getJavaClass().getDeclaredConstructor().newInstance();
        Method theMethod = aFrameworkMethod.getMethod();
        theMethod.invoke(theInstance);

        aRunNotifier.fireTestFinished(theDescription);
    } catch (Exception e) {
        aRunNotifier.fireTestFailure(new Failure(theDescription, e));
    }
}
 
開發者ID:mirkosertic,項目名稱:Bytecoder,代碼行數:15,代碼來源:BytecoderUnitTestRunner.java

示例9: 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));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:45,代碼來源:LoggingListenerTests.java

示例10: 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));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:43,代碼來源:LoggingListenerTests.java

示例11: describeChild

import org.junit.runner.Description; //導入方法依賴的package包/類
@Override
public Description describeChild(Spec child) {
	return Description.createTestDescription(this.getTestClass().getJavaClass(), child.getFullDescription());
}
 
開發者ID:bangarharshit,項目名稱:Oleaster,代碼行數:5,代碼來源:OleasterRunner.java

示例12: describeChild

import org.junit.runner.Description; //導入方法依賴的package包/類
@Override
protected Description describeChild(FrameworkMethod frameworkMethod) {
    return Description.createTestDescription(testClass.getJavaClass(), frameworkMethod.getName());
}
 
開發者ID:mirkosertic,項目名稱:Bytecoder,代碼行數:5,代碼來源:BytecoderUnitTestRunner.java

示例13: describeSelf

import org.junit.runner.Description; //導入方法依賴的package包/類
@Override
Description describeSelf() {
    return Description.createTestDescription(testClass, testMethod.getName());
}
 
開發者ID:TNG,項目名稱:ArchUnit,代碼行數:5,代碼來源:ArchTestMethodExecution.java

示例14: describeSelf

import org.junit.runner.Description; //導入方法依賴的package包/類
@Override
Description describeSelf() {
    return Description.createTestDescription(testClass, ruleField.getName());
}
 
開發者ID:TNG,項目名稱:ArchUnit,代碼行數:5,代碼來源:ArchRuleExecution.java


注:本文中的org.junit.runner.Description.createTestDescription方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。