Skip to main content
Administrator Guide
Last Updated: 2023-06-23
Reference: AUnit Test Annotations

Reference: AUnit Test Annotations

Annotation
Description
Example
@AssemblyTest
Identifies a test as being an AUnit test and associates it with an assembly.
@AssemblyTest(project = "AUnitTrainer", displayLabel = "Citizens of the Cloud")
@UnitTest
Identifies an individual test case.
@UnitTest(startComponent = "Simple-Mediation") public void testSimpleMediation() throws Exception { setMessagePart(0, "test/simple-input.xml", "text/xml"); }
@AssertBefore
Executes assertions before executing a named assembly component or step.
@AssertBefore(id="Store-Output") public void verifySummaryDoc() throws Exception { assertEquals("10", evaluateExpression("parts[0].xpath('count(/summary/wd:WorkerSummary)')")); }
@AssertAfter
Executes assertions after executing a named assembly component or step.
@AssertAfter(id = "Simple-Mediation", step="transform") public void verifySimpleMediation() throws Exception { assertTrue(compare(getTestResourceInputStream("test/simple-expected.xml"), "text/xml", (InputStream) getMediationContext().getMessage().getMessagePart(0, InputStream.class), "text/xml", Comparator.dom)); } @AssertAfter(id="Process", step="transform") public void verifySummary() throws Exception { assertEquals("Ace Developer", evaluateExpression("parts[0].xpath('/wd:WorkerSummary/wd:Name')")); assertEquals("2010-07-27-07:00", evaluateExpression("parts[0].xpath('/wd:WorkerSummary/wd:HireDate')")); }
@AssertAfterCompletion
Executes assertions after the assembly has completed.
@AssertAfterCompletion public void verifyErrorHandling() throws Exception { assertEquals(3, evaluateExpression("props['error.count']")); }
@AtComponent
Defines where the test intercepts the assembly to perform verification and defines the test behavior for the named component.
@AtComponent(id="Get-Workers") public Action handleGetWorkersInvocation() throws Exception { setMessagePart(0, "test/fromworkdayin/workdayin_workers_response.xml", "text/xml"); return new StandardAction(Action.Type.mock); }