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
。 我需要針對我的新實現運行完全相同的一組測試。 我想爲相同的測試設置另一個上下文。
我該怎麼做?