Package com.avoka.tm.test
Class AbstractJUnitTest
java.lang.Object
com.avoka.tm.test.AbstractJUnitTest
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
-
Field Summary
-
Constructor Summary
-
Method Summary
-
Field Details
-
logger
Test logger variable. -
testParams
Test parameters. -
svcDef
Service definition.
-
-
Constructor Details
-
AbstractJUnitTest
public AbstractJUnitTest()
-
-
Method Details
-
invoke
Invoke all unit test methods (annotated withTest
) in the class.- Parameters:
svcDef
- service definitiontestParams
- test parameters
-
cleanup
public void cleanup()Perform test cleanup.- Since:
- 17.10.0
-