2017-04-16 21 views
0

이 테스트 문제와 관련하여 머리를 감쌀 수 없습니다. SUT의 다른 구현에 대해 정확히 동일한 phpunit 테스트를 실행하는 방법은 무엇입니까?

class RepositoryTest extends TestCase { 

    function setUp() { 
     // set implementation in the container 
     container()->set(Repository::class, InMemoryRepository::class); 
    } 

    function test_it_can_save() {...} 
    function test_it_can_delete() {...} 
    function test_it_can_query() {...} 
} 

가 그럼 난이 저장소의 또 다른 구현을 추가 :

내가 좋아하는 인 - 메모리 구현을 사용 테스트 저장소에 대한 테스트를 썼다. SQLRepository이라고 가정 해 보겠습니다. 새로운 구현에 대해 동일한 테스트 세트를 실행해야합니다. 동일한 테스트에 대해 다른 컨텍스트를 설정하고 싶습니다.

어떻게하면됩니까?

답변

0

좋아, 내가 어떻게 해야할지 알 것 같아.

난 그냥 내 초기 테스트를 확장하고이 같은 setUp 방법을 다시로드해야

:

class SQLRepositoryTest extends RepositoryTest { 
    function setUp() { 
     // set another implementation in the container 
     container()->set(Repository::class, SQLRepository::class); 
    } 
}