本文整理汇总了Java中org.junit.runner.Computer类的典型用法代码示例。如果您正苦于以下问题:Java Computer类的具体用法?Java Computer怎么用?Java Computer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Computer类属于org.junit.runner包,在下文中一共展示了Computer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import org.junit.runner.Computer; //导入依赖的package包/类
@Override
public void run() throws EngineException {
try {
Result result = jUnitCore.run(new Computer(), suite.tests());
System.out.println(
String.format(
"Total tests run: %s, Failures: %s, Skips: %s",
result.getRunCount(),
result.getFailureCount(),
result.getIgnoreCount()
)
);
System.exit(result.wasSuccessful() ? 0 : -1);
} catch (SuiteException e) {
throw new EngineException("Some problem occurs in the Junit4 engine", e);
}
}
示例2: testSystem
import org.junit.runner.Computer; //导入依赖的package包/类
@Test
public void testSystem() throws Throwable {
Computer computer = new Computer();
JUnitCore jUnitCore = new JUnitCore();
ByteArrayOutputStream capture = new ByteArrayOutputStream();
final PrintStream printStream = new PrintStream(capture);
TextListener listener = new TextListener(printStream);
jUnitCore.addListener(listener);
PrintStream systemOut = System.out;
System.setOut(printStream);
try {
jUnitCore.run(computer, ExampleTest.class);
} finally {
System.setOut(systemOut);
}
String output = capture.toString("UTF-8");
output = normalizeOutput(output);
String expectedOutput = getResource("/CompositeTest.testSystem.expected.txt");
Assert.assertEquals(expectedOutput, output);
}
示例3: execClass
import org.junit.runner.Computer; //导入依赖的package包/类
private void execClass(final TestClassExecutionData o) {
classData = o;
CLASS_DATA_IN_CONTEXT.set(o);
try {
HtmlRunReporter reporter = o.getHtmlRunReporter();
reporter.hiddenBeforeTestClassExecution();
core.addListener(reporter);
Result result = core.run(Computer.serial(), o.getTestClass());
for (Failure failure : result.getFailures()) {
LOGGER.debug(failure.toString());
}
classData.setCountOfRuns(result.getRunCount());
core.removeListener(reporter);
reporter.hiddenAfterTestClassExecution();
} catch (Throwable e) {
//this is gas
LOGGER.debug("Thread: got EX during JUnitCore execution.", e);
}
CLASS_DATA_IN_CONTEXT.set(null);
classData = null;
}
示例4: status
import org.junit.runner.Computer; //导入依赖的package包/类
/**
* Returns status of JUnite tests execution.
*
* @return the status
* @throws KernelException if any error occurs during JUnit tests execution.
*/
@Override
public Status status() throws KernelException {
try {
return new JunitStatus(this.junit.run(new Computer(), this.suiteForRun.tests()));
} catch (SuiteException e) {
throw new KernelException("Some problem occurs in the Junit4Kernel", e);
}
}
示例5: didBecomeActive
import org.junit.runner.Computer; //导入依赖的package包/类
@Override
public void didBecomeActive(UIApplication application) {
super.didBecomeActive(application);
NSException.registerDefaultJavaUncaughtExceptionHandler();
Computer computer = new Computer();
JUnitCore jUnitCore = new JUnitCore();
jUnitCore.addListener(new TextListener(System.out));
jUnitCore.run(computer, getTestClasses());
}
示例6: build
import org.junit.runner.Computer; //导入依赖的package包/类
/**
* Builds the {@link android.support.test.internal.runner.TestRequest} based on current contents of added classes and methods.
* <p/>
* If no classes have been explicitly added, will scan the classpath for all tests.
*/
public TestRequest build(Instrumentation instr, Bundle bundle) {
if (mTestLoader.isEmpty()) {
// no class restrictions have been specified. Load all classes
loadClassesFromClassPath();
}
Request request = classes(
new AndroidRunnerParams(instr, bundle, mSkipExecution, mPerTestTimeout),
new Computer(),
mTestLoader.getLoadedClasses().toArray(new Class[0]));
return new TestRequest(mTestLoader.getLoadFailures(),
new LenientFilterRequest(request, mFilter));
}
示例7: sortTestsInMultipleClasses
import org.junit.runner.Computer; //导入依赖的package包/类
@Test
public void sortTestsInMultipleClasses() {
Request request = Request.classes(Computer.serial(), TwoTests.class,
TwoTests.class);
fMax.run(request);
List<Description> tests = fMax.sortedLeavesForTest(request);
Description dontSucceed = Description.createTestDescription(
TwoTests.class, "dontSucceed");
assertEquals(dontSucceed, tests.get(0));
assertEquals(dontSucceed, tests.get(1));
}
示例8: runTests
import org.junit.runner.Computer; //导入依赖的package包/类
/**
* Method to execute all tests
*
* @param filename: Filename for the properties file
*/
private static void runTests(String filename) {
System.setProperty("PROPSFILENAME", filename);
JUnitCore core = new JUnitCore();
core.run(new Computer(), AllTests.class);
}
示例9: runTests
import org.junit.runner.Computer; //导入依赖的package包/类
/**
* Method to execute all tests
* @param filename: Filename for the properties file
*/
private static void runTests(String filename) {
System.setProperty("PROPSFILENAME", filename);
JUnitCore core = new JUnitCore();
core.run(new Computer(), AllTests.class);
}
示例10: runJunitTestWithComputer
import org.junit.runner.Computer; //导入依赖的package包/类
private Result runJunitTestWithComputer(Computer computer, Class<?> clazz) {
Result result = JUnitCore.runClasses(computer, clazz);
List<Failure> failures = result.getFailures();
for(Failure failure : failures) {
System.out.println(failure.getMessage());
}
return result;
}
示例11: run
import org.junit.runner.Computer; //导入依赖的package包/类
@Override
public void run() throws Throwable {
Level stdOutLogLevel = Level.INFO;
Level stdErrLogLevel = Level.WARNING;
String unparsedStdOutLogLevel = System.getProperty(STD_OUT_LOG_LEVEL_PROPERTY);
String unparsedStdErrLogLevel = System.getProperty(STD_ERR_LOG_LEVEL_PROPERTY);
if (unparsedStdOutLogLevel != null) {
stdOutLogLevel = Level.parse(unparsedStdOutLogLevel);
}
if (unparsedStdErrLogLevel != null) {
stdErrLogLevel = Level.parse(unparsedStdErrLogLevel);
}
for (String className : testClassNames) {
final Class<?> testClass = Class.forName(className);
List<TestResult> results = new ArrayList<>();
RecordingFilter filter = new RecordingFilter();
if (mightBeATestClass(testClass)) {
JUnitCore jUnitCore = new JUnitCore();
Runner suite = new Computer().getSuite(createRunnerBuilder(), new Class<?>[] {testClass});
Request request = Request.runner(suite);
request = request.filterWith(filter);
jUnitCore.addListener(new TestListener(results, stdOutLogLevel, stdErrLogLevel));
jUnitCore.run(request);
}
// Combine the results with the tests we filtered out
List<TestResult> actualResults = combineResults(results, filter.filteredOut);
writeResult(className, actualResults);
}
}
示例12: classes
import org.junit.runner.Computer; //导入依赖的package包/类
public static Computer classes() {
return new ParallelComputer(true, false);
}
示例13: methods
import org.junit.runner.Computer; //导入依赖的package包/类
public static Computer methods() {
return new ParallelComputer(false, true);
}
示例14: defaultComputer
import org.junit.runner.Computer; //导入依赖的package包/类
static Computer defaultComputer() {
return new Computer();
}
示例15: testCustomJUnitRunnerWithComputer
import org.junit.runner.Computer; //导入依赖的package包/类
@Test
public void testCustomJUnitRunnerWithComputer() throws CompilationFailedException, IOException {
String filename = "src/test/resources/groovy/GroovyRunnerTest.groovy";
Computer computer = new SeleniumComputer("http://www.papajohns.co.uk");
Result result = runJunitTestWithComputer(computer, getGroovyClass(filename));
assertEquals(0, result.getFailureCount());
}