Skip to content

mock-my-test/mockmytest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@mock-my-test/mockmytest

기존 Unit Test 환경의 문제점

  1. caller의 어떤 method에 대한 unit test 개수는, 호출하는 calleemethod 별 가능한 반환값 종류에 따라 exponent하게 증가함

    caller.method() {
        callee.method1();
        callee.method2();
    }
    
    • caller.method에 필요한 unit test 개수 = callee.method1의 반환값 종류 * callee.method2의 반환값 종류
  2. calleemethod들이 잘못 mocking된 경우, caller의 unit test가 성공해도 정상동작하지 않음

  3. 오동작을 확인(e.g., integration test 시행 단계)까지 많은 시간이 소요되며, 원인 파악에 많은 시간과 노력을 필요로 할 수 있음

해결 방안

  • (충분히 잘 작성된) callee의 unit test를 사용하여 mocking하면, caller의 unit test 성공 시 정상 동작이 보장됨

    1. 두 모듈 간 protocol spec에 대해 callee의 unit test 작성

    2. caller의 unit test에서 callee의 unit test로부터 mocking된 객체를 사용

  • protocol spec = (module, initial state, method, input arguments, result)

장점

  1. mocking 실수로 인한 integration test 실패가 사라짐

  2. Unit test 중 protocol에 있는 문제 확인 가능

  3. Protocol 변경이 있을 경우, protocol spec 변경만으로 caller와 callee 모두 잘 동작하는지 확인 가능

예제

number guessing game

  1. callee: 무작위 숫자 생성 및 질문에 대한 답변

  2. caller: 맞추는데 걸린 횟수에 따른 점수 산출

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published