Package com.avoka.tm.test
Class AbstractJUnitTest
- java.lang.Object
-
- com.avoka.tm.test.AbstractJUnitTest
-
public abstract class AbstractJUnitTest extends Object
Provides an abstraction utility for unit testing.
Please find the junit examples below.
JUnit Example (Multiple Tests)
This Groovy example shows how to implement a number of unit tests in a class.
import com.avoka.tm.svc.* import com.avoka.tm.test.* import com.avoka.tm.util.* import com.avoka.tm.vo.* import org.junit.* class MyServiceUnitTest extends AbstractJUnitTest { // Injected at runtime public Logger logger MockRequest request Txn txn @BeforeClass public static void setUp() { } @Before public void beforeTest() { request = new MockRequest() txn = new MockVoBuilder().createTxnOpened() } @Test public void testSvcDefNotNull() { assert svcDef != null } @Test public void testInvokeSvc_noRequestParams() { Map params = [ "svcDef": svcDef, "txn": txn, "request": request, "user": null ] String result = (String) new ServiceInvoker(svcDef).invoke(params) logger.info result assert result != null } @Test public void testInvokeSvc_branch3RequestParam() { request.setParameter("branch3", "test") Map params = [ "svcDef": svcDef, "txn": txn, "request": request, "user": null ] String result = (String) new ServiceInvoker(svcDef).invoke(params) logger.info result assert "branch3".equals(result) } @After public void afterTest() { txn = null request = null } @AfterClass public static void tearDown() { } }
- Since:
- 5.1.4
-
-
Constructor Summary
Constructors Constructor Description AbstractJUnitTest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
cleanup()
Perform test cleanup.void
invoke(SvcDef svcDef, Map testParams)
Invoke all unit test methods (annotated withTest
) in the class.
-