Search in sources :

Example 1 with JUnitTestRun

use of com.oracle.bedrock.testsupport.junit.JUnitTestRun in project oracle-bedrock by coherence-community.

the class JUnitTest method shouldRunJUnitTestsWithClassIncludes.

@Test
public void shouldRunJUnitTestsWithClassIncludes() throws Exception {
    SimpleJUnitTestListener listener = new SimpleJUnitTestListener();
    try (JUnitTestRun jUnit = platform.launch(JUnitTestRun.class, listener.asOption(), TestClasses.of(JUnit4Test.class, MyOtherTest.class).include("(.)*JUnit4Test"))) {
        jUnit.waitFor();
        assertThat(listener.awaitCompletion(2, TimeUnit.MINUTES), is(true));
    }
    assertThat(listener.hasTestFailures(), is(true));
    assertThat(listener.getTestCount(), is(3));
    assertThat(listener.getErrorCount(), is(0));
    assertThat(listener.getFailureCount(), is(1));
    assertThat(listener.getSkipCount(), is(2));
}
Also used : JUnitTestRun(com.oracle.bedrock.testsupport.junit.JUnitTestRun) SimpleJUnitTestListener(com.oracle.bedrock.testsupport.junit.SimpleJUnitTestListener) AbstractJUnit4Test(com.oracle.bedrock.testsupport.junit.AbstractJUnit4Test) MyBadTest(com.oracle.bedrock.testsupport.junit.MyBadTest) JUnit4Test(com.oracle.bedrock.testsupport.junit.JUnit4Test) MyOtherTest(com.oracle.bedrock.testsupport.junit.MyOtherTest) Test(org.junit.Test)

Example 2 with JUnitTestRun

use of com.oracle.bedrock.testsupport.junit.JUnitTestRun in project oracle-bedrock by coherence-community.

the class JUnitTest method shouldRunJUnitTestsWithMethodIncludesAndExcludes.

@Test
public void shouldRunJUnitTestsWithMethodIncludesAndExcludes() throws Exception {
    SimpleJUnitTestListener listener = new SimpleJUnitTestListener();
    try (JUnitTestRun jUnit = platform.launch(JUnitTestRun.class, listener.asOption(), TestClasses.of(JUnit4Test.class, MyOtherTest.class).include("(.)*JUnit4(.)*").exclude("#shouldFail"))) {
        jUnit.waitFor();
        assertThat(listener.awaitCompletion(2, TimeUnit.MINUTES), is(true));
    }
    assertThat(listener.hasTestFailures(), is(false));
    assertThat(listener.getTestCount(), is(2));
    assertThat(listener.getErrorCount(), is(0));
    assertThat(listener.getFailureCount(), is(0));
    assertThat(listener.getSkipCount(), is(2));
}
Also used : MyOtherTest(com.oracle.bedrock.testsupport.junit.MyOtherTest) AbstractJUnit4Test(com.oracle.bedrock.testsupport.junit.AbstractJUnit4Test) JUnit4Test(com.oracle.bedrock.testsupport.junit.JUnit4Test) JUnitTestRun(com.oracle.bedrock.testsupport.junit.JUnitTestRun) SimpleJUnitTestListener(com.oracle.bedrock.testsupport.junit.SimpleJUnitTestListener) AbstractJUnit4Test(com.oracle.bedrock.testsupport.junit.AbstractJUnit4Test) MyBadTest(com.oracle.bedrock.testsupport.junit.MyBadTest) JUnit4Test(com.oracle.bedrock.testsupport.junit.JUnit4Test) MyOtherTest(com.oracle.bedrock.testsupport.junit.MyOtherTest) Test(org.junit.Test)

Example 3 with JUnitTestRun

use of com.oracle.bedrock.testsupport.junit.JUnitTestRun in project oracle-bedrock by coherence-community.

the class JUnitTest method shouldRunJUnitTestsWithMethodExcludes.

@Test
public void shouldRunJUnitTestsWithMethodExcludes() throws Exception {
    SimpleJUnitTestListener listener = new SimpleJUnitTestListener();
    try (JUnitTestRun jUnit = platform.launch(JUnitTestRun.class, listener.asOption(), TestClasses.of(JUnit4Test.class).exclude("#shouldFail"))) {
        jUnit.waitFor();
        assertThat(listener.awaitCompletion(2, TimeUnit.MINUTES), is(true));
    }
    assertThat(listener.hasTestFailures(), is(false));
    assertThat(listener.getTestCount(), is(2));
    assertThat(listener.getErrorCount(), is(0));
    assertThat(listener.getFailureCount(), is(0));
    assertThat(listener.getSkipCount(), is(2));
}
Also used : JUnitTestRun(com.oracle.bedrock.testsupport.junit.JUnitTestRun) SimpleJUnitTestListener(com.oracle.bedrock.testsupport.junit.SimpleJUnitTestListener) AbstractJUnit4Test(com.oracle.bedrock.testsupport.junit.AbstractJUnit4Test) MyBadTest(com.oracle.bedrock.testsupport.junit.MyBadTest) JUnit4Test(com.oracle.bedrock.testsupport.junit.JUnit4Test) MyOtherTest(com.oracle.bedrock.testsupport.junit.MyOtherTest) Test(org.junit.Test)

Example 4 with JUnitTestRun

use of com.oracle.bedrock.testsupport.junit.JUnitTestRun in project oracle-bedrock by coherence-community.

the class JUnitTest method shouldRunJUnitTestsWithClassExcludes.

@Test
public void shouldRunJUnitTestsWithClassExcludes() throws Exception {
    SimpleJUnitTestListener listener = new SimpleJUnitTestListener();
    try (JUnitTestRun jUnit = platform.launch(JUnitTestRun.class, listener.asOption(), TestClasses.of(JUnit4Test.class, MyOtherTest.class).exclude("(.)*MyOtherTest(.)*"))) {
        jUnit.waitFor();
        assertThat(listener.awaitCompletion(2, TimeUnit.MINUTES), is(true));
    }
    assertThat(listener.hasTestFailures(), is(true));
    assertThat(listener.getTestCount(), is(3));
    assertThat(listener.getErrorCount(), is(0));
    assertThat(listener.getFailureCount(), is(1));
    assertThat(listener.getSkipCount(), is(2));
}
Also used : JUnitTestRun(com.oracle.bedrock.testsupport.junit.JUnitTestRun) SimpleJUnitTestListener(com.oracle.bedrock.testsupport.junit.SimpleJUnitTestListener) AbstractJUnit4Test(com.oracle.bedrock.testsupport.junit.AbstractJUnit4Test) MyBadTest(com.oracle.bedrock.testsupport.junit.MyBadTest) JUnit4Test(com.oracle.bedrock.testsupport.junit.JUnit4Test) MyOtherTest(com.oracle.bedrock.testsupport.junit.MyOtherTest) Test(org.junit.Test)

Example 5 with JUnitTestRun

use of com.oracle.bedrock.testsupport.junit.JUnitTestRun in project oracle-bedrock by coherence-community.

the class JUnitTest method shouldRunJUnitTestsAndPrintTextReport.

@Test
public void shouldRunJUnitTestsAndPrintTextReport() throws Exception {
    SimpleJUnitTestListener listener = new SimpleJUnitTestListener();
    File folder = temporaryFolder.newFolder();
    TestClasses tests = TestClasses.of(JUnit4Test.class);
    JUnitTextReporter reporter = new JUnitTextReporter(folder);
    try (JUnitTestRun jUnit = platform.launch(JUnitTestRun.class, tests, reporter.asOption(), listener.asOption())) {
        jUnit.waitFor();
        assertThat(listener.awaitCompletion(2, TimeUnit.MINUTES), is(true));
    }
    dumpReports(folder);
    assertThat(new File(folder, reporter.getReportFileName(JUnit4Test.class)).exists(), is(true));
}
Also used : TestClasses(com.oracle.bedrock.testsupport.junit.options.TestClasses) AbstractJUnit4Test(com.oracle.bedrock.testsupport.junit.AbstractJUnit4Test) JUnit4Test(com.oracle.bedrock.testsupport.junit.JUnit4Test) JUnitTestRun(com.oracle.bedrock.testsupport.junit.JUnitTestRun) SimpleJUnitTestListener(com.oracle.bedrock.testsupport.junit.SimpleJUnitTestListener) File(java.io.File) JUnitTextReporter(com.oracle.bedrock.testsupport.junit.JUnitTextReporter) AbstractJUnit4Test(com.oracle.bedrock.testsupport.junit.AbstractJUnit4Test) MyBadTest(com.oracle.bedrock.testsupport.junit.MyBadTest) JUnit4Test(com.oracle.bedrock.testsupport.junit.JUnit4Test) MyOtherTest(com.oracle.bedrock.testsupport.junit.MyOtherTest) Test(org.junit.Test)

Aggregations

JUnitTestRun (com.oracle.bedrock.testsupport.junit.JUnitTestRun)10 Test (org.junit.Test)10 AbstractJUnit4Test (com.oracle.bedrock.testsupport.junit.AbstractJUnit4Test)9 JUnit4Test (com.oracle.bedrock.testsupport.junit.JUnit4Test)9 MyBadTest (com.oracle.bedrock.testsupport.junit.MyBadTest)9 MyOtherTest (com.oracle.bedrock.testsupport.junit.MyOtherTest)9 SimpleJUnitTestListener (com.oracle.bedrock.testsupport.junit.SimpleJUnitTestListener)9 TestClasses (com.oracle.bedrock.testsupport.junit.options.TestClasses)3 File (java.io.File)2 OptionsByType (com.oracle.bedrock.OptionsByType)1 JavaApplication (com.oracle.bedrock.runtime.java.JavaApplication)1 JUnitTextReporter (com.oracle.bedrock.testsupport.junit.JUnitTextReporter)1 JUnitXmlReporter (com.oracle.bedrock.testsupport.junit.JUnitXmlReporter)1 SimpleJUnitTestRun (com.oracle.bedrock.testsupport.junit.SimpleJUnitTestRun)1