本文整理了Java中org.junit.runner.Request.method
方法的一些代码示例,展示了Request.method
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.method
方法的具体详情如下:
包路径:org.junit.runner.Request
类名称:Request
方法名:method
[英]Create a Request
that, when processed, will run a single test. This is done by filtering out all other tests. This method is used to support rerunning single tests.
[中]创建一个Request
,处理后将运行单个测试。这是通过过滤掉所有其他测试来完成的。此方法用于支持重新运行单个测试。
代码示例来源:origin: junit-team/junit4
private Runner buildRunner(Description each) {
if (each.toString().equals("TestSuite with 0 tests")) {
return Suite.emptySuite();
}
if (each.toString().startsWith(MALFORMED_JUNIT_3_TEST_CLASS_PREFIX)) {
// This is cheating, because it runs the whole class
// to get the warning for this method, but we can't do better,
// because JUnit 3.8's
// thrown away which method the warning is for.
return new JUnit38ClassRunner(new TestSuite(getMalformedTestClass(each)));
}
Class<?> type = each.getTestClass();
if (type == null) {
throw new RuntimeException("Can't build a runner from description [" + each + "]");
}
String methodName = each.getMethodName();
if (methodName == null) {
return Request.aClass(type).getRunner();
}
return Request.method(type, methodName).getRunner();
}
代码示例来源:origin: google/j2objc
private Runner buildRunner(Description each) {
if (each.toString().equals("TestSuite with 0 tests")) {
return Suite.emptySuite();
}
if (each.toString().startsWith(MALFORMED_JUNIT_3_TEST_CLASS_PREFIX)) {
// This is cheating, because it runs the whole class
// to get the warning for this method, but we can't do better,
// because JUnit 3.8's
// thrown away which method the warning is for.
return new JUnit38ClassRunner(new TestSuite(getMalformedTestClass(each)));
}
Class<?> type = each.getTestClass();
if (type == null) {
throw new RuntimeException("Can't build a runner from description [" + each + "]");
}
String methodName = each.getMethodName();
if (methodName == null) {
return Request.aClass(type).getRunner();
}
return Request.method(type, methodName).getRunner();
}
代码示例来源:origin: camunda/camunda-bpm-platform
private Runner buildRunner(Description each) {
if (each.toString().equals("TestSuite with 0 tests")) {
return Suite.emptySuite();
}
if (each.toString().startsWith(MALFORMED_JUNIT_3_TEST_CLASS_PREFIX)) {
// This is cheating, because it runs the whole class
// to get the warning for this method, but we can't do better,
// because JUnit 3.8's
// thrown away which method the warning is for.
return new JUnit38ClassRunner(new TestSuite(getMalformedTestClass(each)));
}
Class<?> type = each.getTestClass();
if (type == null) {
throw new RuntimeException("Can't build a runner from description [" + each + "]");
}
String methodName = each.getMethodName();
if (methodName == null) {
return Request.aClass(type).getRunner();
}
return Request.method(type, methodName).getRunner();
}
代码示例来源:origin: authorjapps/zerocode
private Runnable createRunnable(Class<?> testClass, String testMathod) {
return () -> {
LOGGER.info(Thread.currentThread().getName() + " Parallel Junit test- *Start. Time = " + now());
Result result = (new JUnitCore()).run(Request.method(testClass, testMathod));
LOGGER.info(Thread.currentThread().getName() + " Parallel Junit test- * End. Time = " + now());
if (result.wasSuccessful()) {
passedCounter.incrementAndGet();
} else {
failedCounter.incrementAndGet();
}
};
}
代码示例来源:origin: org.eclipse.che.plugin/che-plugin-testing-junit-runtime
private static List<JUnit4TestReference> getRequestForOneMethod(
String suite, int separatorIndex) {
try {
Class suiteClass = Class.forName(suite.substring(0, separatorIndex));
String method = suite.substring(separatorIndex + 1);
Request request = Request.method(suiteClass, method);
Runner runner = request.getRunner();
return singletonList(new JUnit4TestReference(runner, runner.getDescription()));
} catch (ClassNotFoundException e) {
System.err.print("No test found to run.");
return emptyList();
}
}
代码示例来源:origin: SpoonLabs/nopol
private static void runTest(String test) {
try {
String[] classAndMethod = test.split("#");
System.out.println(test);
Request request = Request.method(Class.forName(classAndMethod[0]), classAndMethod[1]);
JUnitCore junit = new JUnitCore();
junit.addListener(new TextListener(System.out));
junit.run(request);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
代码示例来源:origin: org.robovm/robovm-junit-server
/**
* Run a single method test
*
* @param jUnitCore
* @param className
* @param method
*/
protected void runMethodOnly(JUnitCore jUnitCore, String className, String method) {
try {
jUnitCore.run(Request.method(Class.forName(className), method));
} catch (ClassNotFoundException e) {
error("Test class not found: " + className);
printStackTrace(e);
}
}
代码示例来源:origin: com.mobidevelop.robovm/robovm-junit-server
/**
* Run a single method test
*
* @param jUnitCore
* @param className
* @param method
*/
protected void runMethodOnly(JUnitCore jUnitCore, String className, String method) {
try {
jUnitCore.run(Request.method(Class.forName(className), method));
} catch (ClassNotFoundException e) {
error("Test class not found: " + className);
printStackTrace(e);
}
}
代码示例来源:origin: SpoonLabs/nopol
@Override
public Result call() throws Exception {
JUnitCore runner = new JUnitCore();
runner.addListener(listener);
Request request = Request.method(testClassFromCustomClassLoader(), testCaseName());
try {
return runner.run(request);
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: SpoonLabs/astor
@Override
public Result call() throws Exception {
JUnitCore runner = new JUnitCore();
runner.addListener(listener);
Request request = Request.method(testClassFromCustomClassLoader(), testCaseName());
try {
return runner.run(request);
} catch (Throwable e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.junit
private Runner buildRunner(Description each) {
if (each.toString().equals("TestSuite with 0 tests")) {
return Suite.emptySuite();
}
if (each.toString().startsWith(MALFORMED_JUNIT_3_TEST_CLASS_PREFIX)) {
// This is cheating, because it runs the whole class
// to get the warning for this method, but we can't do better,
// because JUnit 3.8's
// thrown away which method the warning is for.
return new JUnit38ClassRunner(new TestSuite(getMalformedTestClass(each)));
}
Class<?> type = each.getTestClass();
if (type == null) {
throw new RuntimeException("Can't build a runner from description [" + each + "]");
}
String methodName = each.getMethodName();
if (methodName == null) {
return Request.aClass(type).getRunner();
}
return Request.method(type, methodName).getRunner();
}
代码示例来源:origin: org.junit/com.springsource.org.junit
private Runner buildRunner(Description each) {
if (each.toString().equals("TestSuite with 0 tests")) {
return Suite.emptySuite();
}
if (each.toString().startsWith(MALFORMED_JUNIT_3_TEST_CLASS_PREFIX)) {
// This is cheating, because it runs the whole class
// to get the warning for this method, but we can't do better,
// because JUnit 3.8's
// thrown away which method the warning is for.
return new JUnit38ClassRunner(new TestSuite(getMalformedTestClass(each)));
}
Class<?> type = each.getTestClass();
if (type == null) {
throw new RuntimeException("Can't build a runner from description [" + each + "]");
}
String methodName = each.getMethodName();
if (methodName == null) {
return Request.aClass(type).getRunner();
}
return Request.method(type, methodName).getRunner();
}
代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded
private Runner buildRunner(Description each) {
if (each.toString().equals("TestSuite with 0 tests")) {
return Suite.emptySuite();
}
if (each.toString().startsWith(MALFORMED_JUNIT_3_TEST_CLASS_PREFIX)) {
// This is cheating, because it runs the whole class
// to get the warning for this method, but we can't do better,
// because JUnit 3.8's
// thrown away which method the warning is for.
return new JUnit38ClassRunner(new TestSuite(getMalformedTestClass(each)));
}
Class<?> type = each.getTestClass();
if (type == null) {
throw new RuntimeException("Can't build a runner from description [" + each + "]");
}
String methodName = each.getMethodName();
if (methodName == null) {
return Request.aClass(type).getRunner();
}
return Request.method(type, methodName).getRunner();
}
代码示例来源:origin: com.oracle/truffle-tck
private Runner buildRunner(Description each) {
if (each.toString().equals("TestSuite with 0 tests")) {
return Suite.emptySuite();
}
if (each.toString().startsWith(MALFORMED_JUNIT_3_TEST_CLASS_PREFIX)) {
// This is cheating, because it runs the whole class
// to get the warning for this method, but we can't do better,
// because JUnit 3.8's
// thrown away which method the warning is for.
return new JUnit38ClassRunner(new TestSuite(getMalformedTestClass(each)));
}
Class<?> type = each.getTestClass();
if (type == null) {
throw new RuntimeException("Can't build a runner from description [" + each + "]");
}
String methodName = each.getMethodName();
if (methodName == null) {
return Request.aClass(type).getRunner();
}
return Request.method(type, methodName).getRunner();
}
代码示例来源:origin: SpoonLabs/nopol
@Override
public Result call() throws Exception {
JUnitCore runner = new JUnitCore();
runner.addListener(listener);
Request request = Request.method(testClassFromCustomClassLoader(), testCaseName());
return runner.run(request);
}
代码示例来源:origin: SpoonLabs/astor
@Override
public Result call() throws Exception {
JUnitCore runner = new JUnitCore();
runner.addListener(listener);
Request request = Request.method(testClassFromCustomClassLoader(), testCaseName());
return runner.run(request);
}
代码示例来源:origin: fujitsu-pio/io
/**
* .
* @param args .
* @throws ClassNotFoundException .
*/
public static void main(String... args) throws ClassNotFoundException {
int retCode = 0;
String resultMessage = "SUCCESS";
String[] classAndMethod = args[0].split("#");
Request request = Request.method(Class.forName(classAndMethod[0]),
classAndMethod[1]);
Result result = new JUnitCore().run(request);
if (!result.wasSuccessful()) {
retCode = 1;
resultMessage = "FAILURE";
}
System.out.println(resultMessage);
System.exit(retCode);
}
}
代码示例来源:origin: SpectoLabs/hoverfly-java
private void verifyExceptionThrownByDiffAssertionRule(boolean shouldBeThrown, String methodName) {
Request assertStateApi = Request.method(NoDiffAssertionRuleTest.class, methodName);
Result result = new JUnitCore().run(assertStateApi);
if (shouldBeThrown) {
assertThat(result.getFailures()).hasSize(1);
verifyExceptionAssertionErrorWithDiff(result.getFailures().get(0).getException());
} else {
assertThat(result.getFailures()).isEmpty();
}
}
代码示例来源:origin: arquillian/arquillian_deprecated
public TestResult execute(Class<?> testClass, String methodName)
{
DeployableTestBuilder.setProfile(getProfile());
JUnitCore runner = new JUnitCore();
ExpectedExceptionHolder exceptionHolder = new ExpectedExceptionHolder();
runner.addListener(exceptionHolder);
for (RunListener listener : getRunListeners())
runner.addListener(listener);
Result result = runner.run(Request.method(testClass, methodName));
DeployableTestBuilder.clearProfile();
return convertToTestResult(result, exceptionHolder.getException());
}
代码示例来源:origin: effektif/effektif
public static void run(Configuration configuration, Class<?> clazz, String methodName) {
try {
Request request = null;
if (clazz!=null && methodName!=null) {
request = Request.method(clazz, methodName);
} else {
Suite suite = new Suite(new JUnit4Builder(), API_TEST_CLASSES);
request = Request.runner(suite);
}
Configuration originalConfiguration = WorkflowTest.cachedConfiguration;
WorkflowTest.cachedConfiguration = configuration;
JUnitCore junitCore = new JUnitCore();
Result result = junitCore.run(request);
WorkflowTest.cachedConfiguration = originalConfiguration;
checkResult(result);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
内容来源于网络,如有侵权,请联系作者删除!