Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (102)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (322)
Collections:
Other Resources:
JUnit 4.13.2 Source Code Files
JUnit Source Code Files are provided in the
source package file, junit-4.13.2-sources.jar.
You can browse JUnit Source Code files below:
✍: FYIcenter.com
⏎ org/junit/internal/runners/JUnit38ClassRunner.java
package org.junit.internal.runners;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import junit.extensions.TestDecorator;
import junit.framework.AssertionFailedError;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestListener;
import junit.framework.TestResult;
import junit.framework.TestSuite;
import org.junit.runner.Describable;
import org.junit.runner.Description;
import org.junit.runner.Runner;
import org.junit.runner.manipulation.Filter;
import org.junit.runner.manipulation.Filterable;
import org.junit.runner.manipulation.Orderer;
import org.junit.runner.manipulation.InvalidOrderingException;
import org.junit.runner.manipulation.NoTestsRemainException;
import org.junit.runner.manipulation.Orderable;
import org.junit.runner.manipulation.Sortable;
import org.junit.runner.manipulation.Sorter;
import org.junit.runner.notification.Failure;
import org.junit.runner.notification.RunNotifier;
public class JUnit38ClassRunner extends Runner implements Filterable, Orderable {
private static final class OldTestClassAdaptingListener implements
TestListener {
private final RunNotifier notifier;
private OldTestClassAdaptingListener(RunNotifier notifier) {
this.notifier = notifier;
}
public void endTest(Test test) {
notifier.fireTestFinished(asDescription(test));
}
public void startTest(Test test) {
notifier.fireTestStarted(asDescription(test));
}
// Implement junit.framework.TestListener
public void addError(Test test, Throwable e) {
Failure failure = new Failure(asDescription(test), e);
notifier.fireTestFailure(failure);
}
private Description asDescription(Test test) {
if (test instanceof Describable) {
Describable facade = (Describable) test;
return facade.getDescription();
}
return Description.createTestDescription(getEffectiveClass(test), getName(test));
}
private Class<? extends Test> getEffectiveClass(Test test) {
return test.getClass();
}
private String getName(Test test) {
if (test instanceof TestCase) {
return ((TestCase) test).getName();
} else {
return test.toString();
}
}
public void addFailure(Test test, AssertionFailedError t) {
addError(test, t);
}
}
private volatile Test test;
public JUnit38ClassRunner(Class<?> klass) {
this(new TestSuite(klass.asSubclass(TestCase.class)));
}
public JUnit38ClassRunner(Test test) {
super();
setTest(test);
}
@Override
public void run(RunNotifier notifier) {
TestResult result = new TestResult();
result.addListener(createAdaptingListener(notifier));
getTest().run(result);
}
public TestListener createAdaptingListener(final RunNotifier notifier) {
return new OldTestClassAdaptingListener(notifier);
}
@Override
public Description getDescription() {
return makeDescription(getTest());
}
private static Description makeDescription(Test test) {
if (test instanceof TestCase) {
TestCase tc = (TestCase) test;
return Description.createTestDescription(tc.getClass(), tc.getName(),
getAnnotations(tc));
} else if (test instanceof TestSuite) {
TestSuite ts = (TestSuite) test;
String name = ts.getName() == null ? createSuiteDescription(ts) : ts.getName();
Description description = Description.createSuiteDescription(name);
int n = ts.testCount();
for (int i = 0; i < n; i++) {
Description made = makeDescription(ts.testAt(i));
description.addChild(made);
}
return description;
} else if (test instanceof Describable) {
Describable adapter = (Describable) test;
return adapter.getDescription();
} else if (test instanceof TestDecorator) {
TestDecorator decorator = (TestDecorator) test;
return makeDescription(decorator.getTest());
} else {
// This is the best we can do in this case
return Description.createSuiteDescription(test.getClass());
}
}
/**
* Get the annotations associated with given TestCase.
* @param test the TestCase.
*/
private static Annotation[] getAnnotations(TestCase test) {
try {
Method m = test.getClass().getMethod(test.getName());
return m.getDeclaredAnnotations();
} catch (SecurityException e) {
} catch (NoSuchMethodException e) {
}
return new Annotation[0];
}
private static String createSuiteDescription(TestSuite ts) {
int count = ts.countTestCases();
String example = count == 0 ? "" : String.format(" [example: %s]", ts.testAt(0));
return String.format("TestSuite with %s tests%s", count, example);
}
public void filter(Filter filter) throws NoTestsRemainException {
if (getTest() instanceof Filterable) {
Filterable adapter = (Filterable) getTest();
adapter.filter(filter);
} else if (getTest() instanceof TestSuite) {
TestSuite suite = (TestSuite) getTest();
TestSuite filtered = new TestSuite(suite.getName());
int n = suite.testCount();
for (int i = 0; i < n; i++) {
Test test = suite.testAt(i);
if (filter.shouldRun(makeDescription(test))) {
filtered.addTest(test);
}
}
setTest(filtered);
if (filtered.testCount() == 0) {
throw new NoTestsRemainException();
}
}
}
public void sort(Sorter sorter) {
if (getTest() instanceof Sortable) {
Sortable adapter = (Sortable) getTest();
adapter.sort(sorter);
}
}
/**
* {@inheritDoc}
*
* @since 4.13
*/
public void order(Orderer orderer) throws InvalidOrderingException {
if (getTest() instanceof Orderable) {
Orderable adapter = (Orderable) getTest();
adapter.order(orderer);
}
}
private void setTest(Test test) {
this.test = test;
}
private Test getTest() {
return test;
}
}
⏎ org/junit/internal/runners/JUnit38ClassRunner.java
Or download all of them as a single archive file:
File name: junit-4.13.2-sources.jar File size: 234540 bytes Release date: 2021-02-13 Download
⇒ Download and Install junit-4.12.jar
⇐ Download and Install junit-4.13.2.jar
2016-03-28, ≈82🔥, 0💬
Popular Posts:
What Is mail.jar of JavaMail 1.3? I got the JAR file from javamail-1_3.zip. mail.jar in javamail-1_3...
JRE 8 deploy.jar is the JAR file for JRE 8 Java Control Panel and other deploy tools. JRE (Java Runt...
JDK 17 jdk.jshell.jmod is the JMOD file for JDK 17 JShell tool, which can be invoked by the "jshell"...
What Is mail.jar of JavaMail 1.4.2? I got the JAR file from javamail-1.4.2.zip. mail.jar in javamail...
Java Advanced Imaging (JAI) is a Java platform extension API that provides a set of object-oriented ...