跳至主要内容
Administrator Guide
上次更新时间 :2023-06-23
参考信息:AUnit 测试注释

参考信息:AUnit 测试注释

注释
描述
示例
@AssemblyTest
将测试标识为 AUnit 测试,并将其与程序集关联。
@AssemblyTest(project = "AUnitTrainer", displayLabel = "Citizens of the Cloud")
@UnitTest
标识单个测试用例。
@UnitTest(startComponent = "Simple-Mediation") public void testSimpleMediation() throws Exception { setMessagePart(0, "test/simple-input.xml", "text/xml"); }
@AssertBefore
在执行已命名的程序集构成或步骤之前,执行断言。
@AssertBefore(id="Store-Output") public void verifySummaryDoc() throws Exception { assertEquals("10", evaluateExpression("parts[0].xpath('count(/summary/wd:WorkerSummary)')")); }
@AssertAfter
在执行已命名的程序集构成或步骤后执行断言。
@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
在拼装完成后执行断言。
@AssertAfterCompletion public void verifyErrorHandling() throws Exception { assertEquals(3, evaluateExpression("props['error.count']")); }
@AtComponent
定义测试在何处拦截程序集以执行验证,并定义命名组件的测试行为。
@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); }