本文整理匯總了Java中org.junit.runner.Request類的典型用法代碼示例。如果您正苦於以下問題:Java Request類的具體用法?Java Request怎麽用?Java Request使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Request類屬於org.junit.runner包,在下文中一共展示了Request類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: shouldProcessMethodAnnotations
import org.junit.runner.Request; //導入依賴的package包/類
@Test
@DisplayName("Annotations on method")
public void shouldProcessMethodAnnotations() throws Exception {
core.run(Request.aClass(TestWithAnnotations.class));
List<TestResult> testResults = results.getTestResults();
assertThat(testResults)
.hasSize(1)
.flatExtracting(TestResult::getLabels)
.extracting(Label::getValue)
.contains(
"epic1", "epic2", "epic3",
"feature1", "feature2", "feature3",
"story1", "story2", "story3",
"some-owner"
);
}
示例2: main
import org.junit.runner.Request; //導入依賴的package包/類
/**
* .
* @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);
}
示例3: runTaskCase
import org.junit.runner.Request; //導入依賴的package包/類
@Override
public void runTaskCase() throws Exception {
AbstractCaseData.setCaseData(null);
String caseDataInfo = this.tcr.getTaskCase().getCaseDataInfo();
if (!caseDataInfo.isEmpty()) {
CaseData caseData = AbstractCaseData.getCaseData(caseDataInfo);
LOG.debug("Injecting case data: {} = {}", caseDataInfo, caseData.getValue());
AbstractCaseData.setCaseData(caseData);
}
TaskCase tc = this.tcr.getTaskCase();
LOG.debug("Loading case {}", tc.format());
CaseRunListener trl = new CaseRunListener(this.db, this.tcr);
JUnitCore core = new JUnitCore();
core.addListener(trl);
core.run(Request.method(Class.forName(tc.getCaseClass()), tc.getCaseMethod()));
}
示例4: start
import org.junit.runner.Request; //導入依賴的package包/類
@Override
public void start(Stage stage) throws Exception {
AppLauncher.getInstance().setRemoteStage(stage);
new Thread(new Runnable() {
public void run() {
try {
System.out.println("Running junit");
Result r = new JUnitCore().run(Request.method(Class.forName(className), testName));
System.out.println("got result = " + r.wasSuccessful());
}
catch (ClassNotFoundException ex) {
ex.printStackTrace();
} finally {
//System.exit(0);
}
}
}).start();
}
示例5: testTextResultPresentation
import org.junit.runner.Request; //導入依賴的package包/類
@Test
public void testTextResultPresentation() throws Exception {
IResultPresentation presentation = new TextResultPresentation();
final String genericExpected = "" + "Testcase: junit.framework.TestCase.test()" + NEW_LINE
+ "Mutated method: java.lang.Object.hashCode()" + NEW_LINE + "Return value generator: "
+ SAMPLE_RET_VAL_GEN_NAME + NEW_LINE + "Result: %s" + NEW_LINE + ".";
String output;
String expected;
Result result;
result = new Result();
output = presentation.formatTestResultEntry(SAMPLE_TEST_IDENTIFIER, new JUnitTestRunResult(result),
SAMPLE_METHOD_IDENTIFIER, SAMPLE_RET_VAL_GEN_NAME);
expected = String.format(genericExpected, "OK");
assertEquals(expected, output);
result = new JUnitCore().run(Request.method(SampleJUnitTestClass.class, "b"));
output = presentation.formatTestResultEntry(SAMPLE_TEST_IDENTIFIER, new JUnitTestRunResult(result),
SAMPLE_METHOD_IDENTIFIER, SAMPLE_RET_VAL_GEN_NAME);
expected = String.format(genericExpected, "1 of 1 FAILED" + NEW_LINE + "Exception: java.lang.AssertionError");
assertEquals(expected, output);
}
示例6: testDatabaseResultPresentation
import org.junit.runner.Request; //導入依賴的package包/類
@Test
public void testDatabaseResultPresentation() {
IResultPresentation presentation = new DatabaseResultPresentation();
presentation.setExecutionId(ExecutionIdFactory.parseShortExecutionId("EXEC"));
final String genericExpected = "INSERT INTO Test_Result_Import (execution, testcase, method, retValGen, killed, assertErr, exception) VALUES ('EXEC', 'junit.framework.TestCase.test()', 'java.lang.Object.hashCode()', '%s', %s, %s, '%s');";
String output;
String expected;
Result result;
result = new Result();
output = presentation.formatTestResultEntry(SAMPLE_TEST_IDENTIFIER, new JUnitTestRunResult(result),
SAMPLE_METHOD_IDENTIFIER, SAMPLE_RET_VAL_GEN_NAME);
expected = String.format(genericExpected, SAMPLE_RET_VAL_GEN_NAME, false, false, "");
assertEquals(expected, output);
result = new JUnitCore().run(Request.method(SampleJUnitTestClass.class, "b"));
output = presentation.formatTestResultEntry(SAMPLE_TEST_IDENTIFIER, new JUnitTestRunResult(result),
SAMPLE_METHOD_IDENTIFIER, SAMPLE_RET_VAL_GEN_NAME);
expected = String.format(genericExpected, SAMPLE_RET_VAL_GEN_NAME, true, true, AssertionError.class.getName());
assertEquals(expected, output);
}
示例7: main
import org.junit.runner.Request; //導入依賴的package包/類
public static void main(final String[] args) throws Exception {
preFlightTest(args);
table = args[0];
family = args[1];
TestIntegration.args = args;
LOG.info("Starting integration tests");
final JUnitCore junit = new JUnitCore();
final JunitListener listener = new JunitListener();
junit.addListener(listener);
final String singleTest = System.getenv("TEST_NAME");
final Request req;
if (singleTest != null) {
req = Request.method(TestIntegration.class, singleTest);
} else {
req = Request.aClass(TestIntegration.class);
}
final Result result = junit.run(req);
LOG.info("Ran " + result.getRunCount() + " tests in "
+ result.getRunTime() + "ms");
if (!result.wasSuccessful()) {
LOG.error(result.getFailureCount() + " tests failed: "
+ result.getFailures());
System.exit(1);
}
LOG.info("All tests passed!");
}
示例8: getRequestForClasses
import org.junit.runner.Request; //導入依賴的package包/類
private static List<JUnit4TestReference> getRequestForClasses(String[] args) {
List<JUnit4TestReference> suites = new LinkedList<>();
for (String classFqn : args) {
try {
Class<?> aClass = Class.forName(classFqn);
Request request = Request.aClass(aClass);
Runner runner = request.getRunner();
suites.add(new JUnit4TestReference(runner, runner.getDescription()));
} catch (ClassNotFoundException ignored) {
}
}
if (suites.isEmpty()) {
System.err.print("No test found to run.");
return emptyList();
}
return suites;
}
示例9: call
import org.junit.runner.Request; //導入依賴的package包/類
/**
* Wrapper over JUniteCore that runs one test.
*
* @return the result of the test.
* @throws Exception if there was an exception running the test.
*/
@Override
public AugmentedResult call() throws Exception {
JUnitCore jUnitCore = getJUnitCore();
String testName = String.format("%s#%s", test.getDeclaringClass().getCanonicalName(), test.getName());
long start = System.currentTimeMillis();
try {
LOG.info(String.format("STARTING Test %s", testName));
// HACK since for TestSuiteRunner we want to retry, and for TestMethodRunner we don't want to
// The other way would be a RETRY on augmented.properties, but this is independent of the configuration of
// the test.
if (retry) {
TestRunnerRetryingRule.retry();
}
Result result = jUnitCore.run(Request.method(test.getDeclaringClass(), test.getName()));
LOG.info(String.format("FINSHED Test %s in %s, result %s", testName,
Util.TO_PRETTY_FORMAT.apply(System.currentTimeMillis() - start), result.wasSuccessful()? "SUCCEEDED" : "FAILED"));
return new AugmentedResult(testName, result, outputStream);
} finally {
outputStream.close();
}
}
示例10: execute
import org.junit.runner.Request; //導入依賴的package包/類
private static void execute( Class<?> testClass, Notifier notifier, Filter filter )
throws TestSetFailedException
{
final int classModifiers = testClass.getModifiers();
if ( !isAbstract( classModifiers ) && !isInterface( classModifiers ) )
{
Request request = aClass( testClass );
if ( filter != null )
{
request = request.filterWith( filter );
}
Runner runner = request.getRunner();
if ( countTestsInRunner( runner.getDescription() ) != 0 )
{
executeInPlayContext( runner, notifier );
}
}
}
示例11: runTest
import org.junit.runner.Request; //導入依賴的package包/類
private void runTest(Map<String, Bundle> installed, DataInputStream input, DataOutputStream output) throws Exception {
String symbolicName = input.readUTF();
Version version = Version.parseVersion(input.readUTF());
String testClass = input.readUTF();
String testName = input.readUTF();
Bundle testBundle = getTestBundle(installed, input, output, symbolicName, version);
Class<?> testClazz = testBundle.loadClass(testClass);
Result result = new JUnitCore().run(Request.method(testClazz, testName));
if(result.wasSuccessful()) {
output.writeUTF(SUCCESS);
} else {
Failure failure = result.getFailures().get(0);
output.writeUTF(FAIL);
output.writeUTF(failure.getMessage());
}
output.flush();
}
示例12: run
import org.junit.runner.Request; //導入依賴的package包/類
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);
}
}
示例13: main
import org.junit.runner.Request; //導入依賴的package包/類
public static void main(String []argv)
{
int maxIterations = 10;
JUnitCore junit = new JUnitCore();
Result result = null;
int iter = 0;
do
{
result = junit.run(Request.method(TraversalsTests.class, "testDepthFirstOnCircle"));
iter++;
System.out.println("Failures " + result.getFailureCount());
if (result.getFailureCount() > 0)
{
for (Failure failure : result.getFailures())
{
failure.getException().printStackTrace();
}
}
} while (result.getFailureCount() == 0 && iter < maxIterations);
}
示例14: main
import org.junit.runner.Request; //導入依賴的package包/類
public static void main(String []argv)
{
JUnitCore junit = new JUnitCore();
Result result = null;
do
{
result = junit.run(Request.method(PropertyIndexingTests.class, "derivedPropertyIndexing"));
} while (result.getFailureCount() == 0 && false);
System.out.println("Failures " + result.getFailureCount());
if (result.getFailureCount() > 0)
{
for (Failure failure : result.getFailures())
{
failure.getException().printStackTrace();
}
}
System.exit(0);
}
示例15: main
import org.junit.runner.Request; //導入依賴的package包/類
public static void main(String[] args) throws ClassNotFoundException {
String arg = "eu.hgross.blaubot.test.AllSuite";
if (args.length > 0) {
arg = args[0];
}
String[] classAndMethod = arg.split("#");
Request request;
if (classAndMethod.length == 1) {
request = Request.classes(Class.forName(classAndMethod[0]));
} else {
request = Request.method(Class.forName(classAndMethod[0]), classAndMethod[1]);
}
Result result = new JUnitCore().run(request);
for (Failure failure : result.getFailures()) {
System.out.println(failure.getMessage());
}
System.exit(result.wasSuccessful() ? 0 : 1);
}