Building Test Codes for Unit Test Automation of Java Programs

단위 테스트 자동화를 위한 자바 프로그램 테스트 코드 구축

  • 윤회진 (협성대학교 컴퓨터공학과)
  • Received : 2010.11.02
  • Accepted : 2010.12.20
  • Published : 2010.12.31

Abstract

Agile development is mentioned a lot by developers these days. XP or Scrum is one of the popular development processes, and it says that unit test automation would drive an agile development successful. The success of unit test automation depends on how well to compare an execution result to its own expected result. that is why this paper focuses on the comparison part. This paper introduces how to build test codes for unit testing, and then concludes with mentioning two considerations of unit testing automation. First, test codes for void-typed methods need Mock Framework to monitor their behavior. Second, the comparison of execution results and expected results is hard to implement in case of testing void-typed methods. We check every sentences of a test path to decide if the testing is fail or pass.

애자일 개발의 XP와 Scrum을 중심으로 단위 테스트 자동화의 중요성이 커지고 있다. 그러나 테스트 결과, 즉 통과 또는 실패를 자동으로 결정하기 위해서는 테스트 실행 결과와 예상 결과를 비교하는 과정이 필요하다. 이 부분의 구현이 자동화의 성패를 좌우한다. 본 연구는 단위 테스트 자동화를 위한 테스트 코드 작성을 소개하고, 테스트 코드 구현에서 고려해야할 사항을 언급한다. 첫째, void 형태의 메소드의 경우 테스트 데이터 실행 결과를 명시적으로 구하기 어려운 문제를 본 연구에서는 Mock 프레임워크를 사용하여 해결하였다. 둘째, void 형태의 메소드의 경우, criteria로 인해 구성된 테스트 경로상의 모든 문장들이 제대로 수행되었는지 하나씩 살펴보아야 하는지, 아니면 최종 문장에 대해서만 보아야 하는지의 문제이다. 본 연구에서는 Mock 프레임워크의 verify 기능을 활용하여 매 순간 제대로 실행되어져야 하는 메소드 호출을 중심으로 명확한 매개변수들을 사용하여 호출이 일어났는 지를 확인하고, 그 결과들이 모두 예상 결과와 맞을 때, 해당 테스트 케이스에 대한 테스트를 통과한 것으로 결정하였다.

Keywords