本文整理匯總了Java中org.junit.runner.Result類的典型用法代碼示例。如果您正苦於以下問題:Java Result類的具體用法?Java Result怎麽用?Java Result使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Result類屬於org.junit.runner包,在下文中一共展示了Result類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: doRun
import org.junit.runner.Result; //導入依賴的package包/類
public Result doRun(Test suite, boolean wait) {
MarathonTestRunner runner = new MarathonTestRunner();
runReportDir = argProcessor.getReportDir();
String resultsDir = new File(runReportDir, "results").getAbsolutePath();
if (runReportDir != null) {
System.setProperty(Constants.PROP_REPORT_DIR, runReportDir);
System.setProperty(Constants.PROP_IMAGE_CAPTURE_DIR, runReportDir);
System.setProperty("allure.results.directory", resultsDir);
runner.addListener(new AllureMarathonRunListener());
}
runner.addListener(new TextListener(System.out));
Result result = runSuite(suite, runner);
MarathonTestCase.reset();
if (runReportDir != null && !argProcessor.isSkipreports()) {
AllureUtils.launchAllure(false, resultsDir, new File(runReportDir, "reports").getAbsolutePath());
}
return result;
}
示例2: firstShouldBeFirstBeforeLastAfter
import org.junit.runner.Result; //導入依賴的package包/類
@Test
public void firstShouldBeFirstBeforeLastAfter() {
Result result = TestRunner.runTest(ThreeRules.class);
assertThat(result.wasSuccessful()).isTrue();
assertThat(counter.get()).isEqualTo(9);
assertThat(invocations[0].beforeInvocation).isEqualTo(1);
assertThat(invocations[1].beforeInvocation).isEqualTo(2);
assertThat(invocations[2].beforeInvocation).isEqualTo(3);
assertThat(invocations[0].testInvocation).isEqualTo(4);
assertThat(invocations[1].testInvocation).isEqualTo(5);
assertThat(invocations[2].testInvocation).isEqualTo(6);
assertThat(invocations[2].afterInvocation).isEqualTo(7);
assertThat(invocations[1].afterInvocation).isEqualTo(8);
assertThat(invocations[0].afterInvocation).isEqualTo(9);
}
示例3: main
import org.junit.runner.Result; //導入依賴的package包/類
public static void main(String[] args) {
final Result result =
JUnitCore.runClasses(
codeu.chat.common.SecretTest.class,
codeu.chat.relay.ServerTest.class,
codeu.chat.server.BasicControllerTest.class,
codeu.chat.server.RawControllerTest.class,
codeu.chat.util.TimeTest.class,
codeu.chat.util.UuidTest.class,
codeu.chat.util.store.StoreTest.class
);
for (final Failure failure : result.getFailures()) {
System.out.println(failure.toString());
}
System.out.println(result.wasSuccessful());
}
示例4: testRunFinished
import org.junit.runner.Result; //導入依賴的package包/類
/**
*
* @see org.junit.runner.notification.RunListener#testRunFinished(org.junit.runner.Result)
*/
@Override
public void testRunFinished( Result result ) throws Exception {
if (log.isDebugEnabled()) {
log.debug("testRunFinished(): result " + "| failure count: " + result.getFailureCount()
+ "| ignored count: " + result.getIgnoreCount() + "| tests run count: "
+ result.getRunCount() + "| Run time: " + result.getRunTime() + "ms.");
}
if (lastSuiteName != null) {
logger.endSuite();
lastSuiteName = null; // Run finished. A lastSuiteName should not be visible between runs
}
// end the run
logger.endRun();
super.testRunFinished(result);
}
示例5: main
import org.junit.runner.Result; //導入依賴的package包/類
public static void main(String[] args) {
final Result result =
JUnitCore.runClasses(
codeu.chat.common.SecretTest.class,
codeu.chat.relay.ServerTest.class,
codeu.chat.server.BasicControllerTest.class,
codeu.chat.server.RawControllerTest.class,
codeu.chat.util.TimeTest.class,
codeu.chat.util.TokenizerTest.class,
codeu.chat.util.UuidTest.class,
codeu.chat.util.store.StoreTest.class
);
for (final Failure failure : result.getFailures()) {
System.out.println(failure.toString());
}
System.out.println(result.wasSuccessful());
}
示例6: runTestSuiteAgainst
import org.junit.runner.Result; //導入依賴的package包/類
/**
* Creates and runs a JUnit test runner for testSuite.
*
* @param testSuite the class defining test cases to run
* @param view a UI component to report test failures to
* @return the counts of failures and total test cases.
*/
static RunResult runTestSuiteAgainst(Class testSuite, View view)
{
if(testSuite == null)
throw new NullPointerException("testSuite");
if(view == null)
throw new NullPointerException("view");
Result result = new JUnitCore().run(testSuite);
if (result.getFailureCount() > 0)
{
for (Failure f : result.getFailures())
view.declarePassProgramTestFailure(f.getTrace());
}
return new RunResult(result.getFailureCount(), result.getRunCount());
}
示例7: main
import org.junit.runner.Result; //導入依賴的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);
}
示例8: failsWithExpectedTimeoutButWrongError
import org.junit.runner.Result; //導入依賴的package包/類
@Test
public void failsWithExpectedTimeoutButWrongError() {
Result result = TestRunner.runTest(FailsWithExpectedTimeoutButWrongError.class);
assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
String expectedMessage = "\n"
+ "Expected: (an instance of java.util.concurrent.TimeoutException and exception with message a string containing \"this is a message for FailsWithExpectedTimeoutButWrongError\")"
+ "\n" + " "
+ "but: an instance of java.util.concurrent.TimeoutException <java.lang.NullPointerException> is a java.lang.NullPointerException";
assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class)
.hasMessageContaining(expectedMessage);
}
示例9: assertResultHasNoFailures
import org.junit.runner.Result; //導入依賴的package包/類
/**
* Checks that result has no failures.
* Print all the failures in error message if there are any.
*/
public static void assertResultHasNoFailures(Result result) {
List<Failure> failures = result.getFailures();
assertThat(failures)
.as("No failures expected. Failures: %s",
failures.stream()
.map(ResultAssertions::formFailureDescription)
.collect(Collectors.toList()))
.isEmpty();
}
示例10: testBrokenCategoryAndParameterized
import org.junit.runner.Result; //導入依賴的package包/類
@Test
public void testBrokenCategoryAndParameterized() {
Request request = Request.aClass(BrokenCategoryClass.class);
ExposedParameterized runner = (ExposedParameterized) request.getRunner();
request = request.filterWith(new CategoryFilter(
(ExposedBlockJUnit4ClassRunnerWithParameters) runner.getChildren().get(0)));
Result result = new JUnitCore().run(request);
assertEquals(
"Yeah!! This might actually mean we've upgraded to JUnit 4.13. Hurry up already and delete this hack.",
1, result.getRunCount());
}
示例11: failsOnSecondAttempt
import org.junit.runner.Result; //導入依賴的package包/類
@Test
public void failsOnSecondAttempt() {
Result result = TestRunner.runTest(FailsOnSecondAttempt.class);
assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
assertThat(failure.getException()).isExactlyInstanceOf(CustomException.class)
.hasMessage(FailsOnSecondAttempt.message);
assertThat(FailsOnSecondAttempt.count).isEqualTo(2);
}
示例12: main
import org.junit.runner.Result; //導入依賴的package包/類
public static void main(String[] args) throws Exception {
Result result = JUnitCore.runClasses(Bug_for_Next.class);
for (Failure fail : result.getFailures()) {
System.out.println(fail.toString());
}
if (result.wasSuccessful()) {
System.out.println("All tests finished successfully...");
}
}
示例13: main
import org.junit.runner.Result; //導入依賴的package包/類
public static void main(String[] args) {
final Result result =
JUnitCore.runClasses(
codeu.chat.common.SecretTest.class,
codeu.chat.relay.ServerTest.class,
codeu.chat.server.BasicControllerTest.class,
codeu.chat.server.RawControllerTest.class,
codeu.chat.util.TimeTest.class,
codeu.chat.util.UuidTest.class,
codeu.chat.util.store.StoreTest.class,
codeu.chat.util.TokenizerTest.class,
codeu.chat.server.ControllerTest.class
);
System.out.println("\n===================== Test Status ====================");
System.out.println(String.format("%d tests run.", result.getRunCount()));
if (result.wasSuccessful()) {
System.out.println("All tests passed.");
} else {
System.out.println(String.format("%d tests failed.", result.getFailureCount()));
System.out.println("\nFailures:");
for (final Failure failure : result.getFailures()) {
System.out.println(failure.toString());
}
}
System.out.println("======================================================\n");
System.exit(result.wasSuccessful() ? 0 : -1);
}
示例14: failingTestShouldFailOneTimeWhenRepeatIsThree
import org.junit.runner.Result; //導入依賴的package包/類
@Test
public void failingTestShouldFailOneTimeWhenRepeatIsThree() {
Result result = TestRunner.runTest(FailingTestShouldFailOneTimeWhenRepeatIsThree.class);
assertThat(result.wasSuccessful()).isFalse();
List<Failure> failures = result.getFailures();
assertThat(failures.size()).as("Failures: " + failures).isEqualTo(1);
Failure failure = failures.get(0);
assertThat(failure.getException()).isExactlyInstanceOf(AssertionError.class)
.hasMessage(ASSERTION_ERROR_MESSAGE);
assertThat(FailingTestShouldFailOneTimeWhenRepeatIsThree.count).isEqualTo(1);
}
示例15: passesOnThirdAttempt
import org.junit.runner.Result; //導入依賴的package包/類
@Test
public void passesOnThirdAttempt() {
Result result = TestRunner.runTest(PassesOnThirdAttempt.class);
assertThat(result.wasSuccessful()).isTrue();
assertThat(PassesOnThirdAttempt.count).isEqualTo(3);
}