Acceptance Testing - Functional testing of a user story

The Fundamental Test-Driven Development Cycle 에서 Acceptance Test 는 TDD Cycle 과 통합될 수 있다.

Factory Acceptance Test is Prior to delivery or final installation, clients want to make sure that equipment operates as intended without disturbances occurring on site. In achieving this, clients are therefore able to verify that all specifications and contractual requirements have been met.

Extreme Programming 에서는 클라이언트와 개발자간의 원활한 소통과 명확한 요구사항 이해를 위해 User Story 를 기반으로 한다. 그렇기 때문에 Extreme Programming 에서는 인수 테스트를 아래와 같이 소개하고 있다.

Acceptance testing is Functional testing of a user story by the software development team during the implementation phase.

Practical Test Pyramid 에서는 Acceptance Test 를 아래와 같이 소개하고 있다.

At one point you should make sure to test that your software works correctly from a user's perspective, not just from a technical perspective.

Lean-Agile Acceptance Test-Driven Development: Better Software Through Collaboration:

인수 테스트의 개념은 테스트 의도에 따라 정해지는 것이 테스트를 어떻게 구현하는지에 따라 정해지는 것은 아니다. 유닛 레벨, 통합 레벨, 사용자 인터페이스 레벨에서 인수 테스트를 적용할 수 있다.

The Importance of End-to-End Testing: A Horror Story:

Nat was once brought onto a project that had been using TDD since its inception. The team had been writing acceptance tests to capture requirements and show progress to their customer representatives. They had been writing unit tests for the classes of the system, and the internals were clean and easy to change. They had been making great progress, and the customer representatives had signed off all the implemented features on the basis of the passing acceptance tests.

But the acceptance tests did not run end-to-end—they instantiated the system’s internal objects and directly invoked their methods. The application actually did nothing at all. Its entry point contained only a single comment:

// TODO implement this

Additional feedback loops, such as regular show-and-tell sessions, should have been in place and would have caught this problem.

How to write Acceptance Test

Format:

Feature: 로그인 실패 시 계정 잠금 기능

Scenario: 연속된 로그인 실패로 계정이 잠긴다
  Given 등록된 사용자 계정이 있다
  When 잘못된 비밀번호로 5회 연속 로그인을 시도한다
  Then 계정이 잠금 상태가 된다
  And 올바른 비밀번호로도 로그인이 불가능하다
  And 계정 잠금 해제 이메일이 발송된다
  • 비즈니스 용어 사용
  • 명확하고 구체적인 시나리오 작성

Tools

Golden Master Testing 와 같이 Integration Testing 을 하는 경우 테스트 환경을 실제 운영 환경과 유사하게 구축해야 한다. 이때 Testcontainers 를 사용한다. 인수 테스트도 비슷하게할 수 있다.

또한 Scenario Test(use case flow tests) 를 위해서 Selenium 을 사용할 수도 있다.

References

  • Lean-Agile Acceptance Test-Driven Development: Better Software Through Collaboration / Kenneth Pugh
  • Growing Object-Oriented Software, Guided by Tests / Steve Freeman, Nat Pryce