Java Code Examples for org.junit.runner.JUnitCore#runClasses()

The following examples show how to use org.junit.runner.JUnitCore#runClasses() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestRunner.java    From codeu_project_2017 with Apache License 2.0 6 votes vote down vote up
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());
}
 
Example 2
Source File: TestExceptionInBeforeClassHooks.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Test
public void testExceptionInBeforeClassFailsTheTest() {
  Result runClasses = JUnitCore.runClasses(Nested1.class);
  assertFailureCount(1, runClasses);
  Assert.assertEquals(1, runClasses.getRunCount());
  Assert.assertTrue(runClasses.getFailures().get(0).getTrace().contains("foobar"));
}
 
Example 3
Source File: TestDataStatementTest.java    From neodymium-library with MIT License 5 votes vote down vote up
@Test
public void testSpecialCharacterTestId() throws Throwable
{
    // special characters in testId
    // parenthesis will be converted to to brackets
    Result result = JUnitCore.runClasses(SpecialCharacterTestId.class);
    checkPass(result, 7, 0, 0);
}
 
Example 4
Source File: TestDataStatementTest.java    From neodymium-library with MIT License 5 votes vote down vote up
@Test
public void testDuplicateTestId() throws Exception
{
    // more than one entry with the same "testId"
    Result result = JUnitCore.runClasses(DuplicateTestId.class);
    checkPass(result, 6, 0, 0);
}
 
Example 5
Source File: ParameterStatementTest.java    From neodymium-library with MIT License 5 votes vote down vote up
@Test
public void testGeneratorCanNotSetPrivateSField()
{
    // test that a private field can not be set
    Result result = JUnitCore.runClasses(GeneratorCanNotSetPrivateField.class);
    checkFail(result, 1, 0, 1, "Could not set parameter due to it is not public or it is final");
}
 
Example 6
Source File: TestDataStatementTest.java    From neodymium-library with MIT License 5 votes vote down vote up
@Test
public void testGrandChildPackageTestDataInheritance()
{
    // test multiple inheritance of package test data
    Result result = JUnitCore.runClasses(GrandChildPackageTestDataInheritance.class);
    checkPass(result, 1, 0, 0);
}
 
Example 7
Source File: TestDataStatementTest.java    From neodymium-library with MIT License 5 votes vote down vote up
@Test
public void testPackageTestDataInheritance()
{
    // test inheritance of package test data
    Result result = JUnitCore.runClasses(PackageTestDataInheritance.class);
    checkPass(result, 1, 0, 0);
}
 
Example 8
Source File: TestDataStatementTest.java    From neodymium-library with MIT License 5 votes vote down vote up
@Test
public void testCanReadDataSetXML()
{
    // test data set xml is read
    Result result = JUnitCore.runClasses(CanReadDataSetXML.class);
    checkPass(result, 1, 0, 0);
}
 
Example 9
Source File: TestExceptionInBeforeClassHooks.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Test
public void testExceptionWithinBefore() {
  Result runClasses = JUnitCore.runClasses(Nested3.class);
  assertFailureCount(1, runClasses);
  Assert.assertEquals(1, runClasses.getRunCount());
  Assert.assertTrue(runClasses.getFailures().get(0).getTrace().contains("foobar"));
}
 
Example 10
Source File: ParameterStatementTest.java    From neodymium-library with MIT License 5 votes vote down vote up
@Test
public void testGeneratorTooFewElements()
{
    // one test iteration with two parameter fields, but just one data set
    Result result = JUnitCore.runClasses(GeneratorTooFewElements.class);
    checkFail(result, 1, 0, 1, "Number of parameters (1) and fields (2) annotated with @Parameter must match!");
}
 
Example 11
Source File: PtlBlockJUnit4ClassRunnerWithParametersTest.java    From hifive-pitalium with Apache License 2.0 5 votes vote down vote up
/**
 * {@link ParameterizedAfterClass}を設定したメソッドのバリデーションテスト
 */
@Test
public void testValidateParameterizedAfterClass() throws Exception {
	Result result = JUnitCore.runClasses(ValidateParameterizedAfterClass.class);
	assertThat(result.getFailureCount(), is(3));

	for (Failure failure : result.getFailures()) {
		assertThat(
				failure.getMessage(),
				is(anyOf(equalTo("Method afterClass() should be static"),
						equalTo("Method afterClass() should be public"),
						//							equalTo("Method afterClass() should have 1 parameters"),
						equalTo("Method afterClass() should be void"))));
	}
}
 
Example 12
Source File: DataUtilsTest.java    From neodymium-library with MIT License 5 votes vote down vote up
@Test
public void testDataUtils() throws Exception
{
    // test the data utils
    Result result = JUnitCore.runClasses(DataUtilsTests.class);
    checkPass(result, 9, 0, 0);
}
 
Example 13
Source File: TestCodecReported.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Test
public void testCorrectCodecReported() {
  Result r = JUnitCore.runClasses(Nested1.class);
  Assert.assertEquals(1, r.getFailureCount());
  Assert.assertTrue(super.getSysErr(),
      super.getSysErr().contains("codec=" + Nested1.codecName));
}
 
Example 14
Source File: ParameterStatementTest.java    From neodymium-library with MIT License 5 votes vote down vote up
@Test
public void testParameterFieldWithoutGenerator()
{
    // test parameter annotated class members without an generator function (@Parameters)
    Result result = JUnitCore.runClasses(ParameterFieldButNoGenerator.class);
    checkPass(result, 1, 0, 0);
}
 
Example 15
Source File: ParameterStatementTest.java    From neodymium-library with MIT License 5 votes vote down vote up
@Test
public void testGeneratorAutoTypeConversion()
{
    // test auto type conversion from string to various data types, as well as arbitrary type injection
    Result result = JUnitCore.runClasses(GeneratorAutoTypeConversion.class);
    checkPass(result, 1, 0, 0);
}
 
Example 16
Source File: TestJUnitRuleOrder.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
@Test
public void testRuleOrder() {
  JUnitCore.runClasses(Nested.class);
  Assert.assertEquals(
      Arrays.toString(stack.toArray()), "[@Rule before, @Before, @After, @Rule after, @AfterClass]");
}
 
Example 17
Source File: NeodymiumContextTest.java    From neodymium-library with MIT License 4 votes vote down vote up
@Test
public void testBrowserContextSetup() throws Exception
{
    Result result = JUnitCore.runClasses(BrowserContextSetup.class);
    checkPass(result, 1, 0, 0);
}
 
Example 18
Source File: NeodymiumContextTest.java    From neodymium-library with MIT License 4 votes vote down vote up
@Test
public void testSelenideConfigurationShortcuts() throws Exception
{
    Result result = JUnitCore.runClasses(SelenideConfigurationShortcuts.class);
    checkPass(result, 4, 0, 0);
}
 
Example 19
Source File: ToothpickRuleTest.java    From toothpick with Apache License 2.0 4 votes vote down vote up
@Test
public void testRuleIsIntroducedAndEvaluated() {
  SimpleTest.wasRun = false;
  JUnitCore.runClasses(SimpleTest.class);
  assertThat(SimpleTest.wasRun, is(true));
}
 
Example 20
Source File: CucumberTest.java    From neodymium-library with MIT License 4 votes vote down vote up
@Test
public void testSetBrowserViaTag() throws Exception
{
    Result result = JUnitCore.runClasses(CucumberSetBrowserViaTag.class);
    checkPass(result, 1, 0, 0);
}