주 컨텐츠로 이동
Administrator Guide
최종 업데이트: 2023-06-23
개념: AUnit 테스트

개념: AUnit 테스트

AUnit은 어셈블리의 단위 테스트를 개발하고 실행할 수 있게 해주는 Workday Studio 테스트 프레임워크입니다. 어셈블리 프로젝트에서 생성한 테스트 스켈레톤을 사용하여 Java로 AUnit 테스트를 개발할 수 있습니다. AUnit 테스트 스켈레톤은 다음 기능을 지원합니다.
  • 액션
  • 주석
  • 어설션
이러한 기능을 사용하여 어셈블리의 테스트 케이스를 빌드할 수 있습니다.
예를 들어 다음과 같습니다.
package com.workday.training.aunit; import java.io.InputStream; import com.workday.aunit.AssemblyTestCase; import com.workday.aunit.actions.Action; import com.workday.aunit.actions.StandardAction; import com.workday.aunit.annotations.AssemblyTest; import com.workday.aunit.annotations.AssertAfter; import com.workday.aunit.annotations.AtComponent; import com.workday.aunit.annotations.UnitTest; @AssemblyTest(project = "AUnitTrainer", displayLabel = "Citizens of the Cloud") public class SimpleMediationTest extends AssemblyTestCase { @UnitTest(startComponent = "Simple-Mediation") public void testSimpleMediation() throws Exception { setMessagePart(0, "test/simple-input.xml", "text/xml"); } // Using the @AssertAfter annotation and the assertTrue assertion. // @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)); } @AtComponent(id="Next-Thing") public Action handleAfterMediation() throws Exception { return new StandardAction(Action.Type.terminate); } }

주석

모든 AUnit 테스트에는 다음이 포함되어야 합니다.
@AssemblyTest
주석 이 주석은 AUnit 테스트를 식별하고 테스트를 조립품 프로젝트와 연결할 수 있도록 합니다. 예를 들어 다음과 같습니다.
@AssemblyTest(project = "AUnitTrainer")
테스트 방법에 대한 주석은 어셈블리 처리 체계에서 단위 테스트의 시작점을 정의합니다. 예를 들어 다음과 같습니다.
@UnitTest(startComponent = "Simple-Mediation")

어설션

어설션은 부울 테스트 조건을 정의합니다. 어설션이 실패하면 AUnit은 어셈블리 실행을 중단하고 테스트 결과를 실패로 표시합니다. 예상치 못한 예외가 발생하면 AUnit이 조립품 실행을 중단하고 테스트 결과를 오류로 표시합니다.
예: 아래 샘플에서는
@AssertAfter
주석 및
assertTrue
어설션을 사용하여 조정이 실행된 후 root 메시지 부분에 필요한 XML이 포함되어 있는지 확인합니다.
@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)); }

액션

액션은 어셈블리 실행이 구성요소 또는 종료점에 도달할 때의 AUnit 테스트 동작을 정의합니다. 예를 들어 다음과 같습니다.
@AtComponent(id="Next-Thing") public Action handleAfterMediation() throws Exception { return new StandardAction(Action.Type.terminate); }