Package com.zfabrik.z2unit
Class Z2UnitTestRunner
java.lang.Object
org.junit.runner.Runner
com.zfabrik.z2unit.Z2UnitTestRunner
- All Implemented Interfaces:
org.junit.runner.Describable
,org.junit.runner.manipulation.Filterable
,org.junit.runner.manipulation.Sortable
public class Z2UnitTestRunner
extends org.junit.runner.Runner
implements org.junit.runner.manipulation.Filterable, org.junit.runner.manipulation.Sortable
JUnit4 Unit test runner that, when invoked client-side, sends a request server-side to run unit tests of the given class on the server side.
When executed server side this runner delegates all work to the default implementation. A server-side JUnit RunListener logs JUnit events
and streams them back to the client side.
The client-side execution of this test runner parses streamed events and replays them as JUnit events to the local JUnit execution context, so that to the client-side the results "look" like local execution events.
Tests executed with this test runner should be annotated using Z2UnitTest
to configure the Java component that holds the unit test
class like this.
@RunWith(Z2UnitTestRunner.class) @Z2UnitTest(componentName="z2unit.sometests") public class SomeTests { @BeforeClass public static void beforeClass() { System.out.println("beforeClass"); } @AfterClass public static void afterClass() { System.out.println("afterClass"); } @Before public void before() { System.out.println("before"); } @After public void after() { System.out.println("after"); } @Test public void succeedingTest() { Assert.assertTrue("This test succeeds", true); } }This unit test runner also supports filtered and sorted test execution, i.e. in particular single method tests.
The Z2 Unit feature is not usable for JUnit 5 tests. While this feature will be preserved for existing JUnit 4 based tests, new implementations should use the Z2 Jupiter feature (see Z2JupiterTestable).
- See Also:
Z2UnitTest
-
Field Details
-
APPLICATION_OCTET_STREAM
- See Also:
- Constant Field Values
-
-
Constructor Details
-
Z2UnitTestRunner
- Throws:
org.junit.runners.model.InitializationError
-
-
Method Details
-
filter
public void filter(org.junit.runner.manipulation.Filter filter) throws org.junit.runner.manipulation.NoTestsRemainException- Specified by:
filter
in interfaceorg.junit.runner.manipulation.Filterable
- Throws:
org.junit.runner.manipulation.NoTestsRemainException
-
sort
public void sort(org.junit.runner.manipulation.Sorter sorter)- Specified by:
sort
in interfaceorg.junit.runner.manipulation.Sortable
-
getDescription
public org.junit.runner.Description getDescription()- Specified by:
getDescription
in interfaceorg.junit.runner.Describable
- Specified by:
getDescription
in classorg.junit.runner.Runner
-
testCount
public int testCount()- Overrides:
testCount
in classorg.junit.runner.Runner
-
run
public void run(org.junit.runner.notification.RunNotifier runNotifier)- Specified by:
run
in classorg.junit.runner.Runner
-