9
我有泛型代碼設置和拆除NHibernate,我幾乎需要我所有的測試。有沒有辦法在一個地方包含「需要所有測試」代碼,然後將其應用於所有測試? (即像NUnit的的setup
和teardown
方法)如何在MSpec中運行每個測試的設置和拆卸代碼?
[Subject("Accessing the TAE allocation page")]
public class when_a_request_to_the_tae_allocation_page_is_made
{
Establish context =() => NHTestHelper.StartTest(); //need for all tests
Because of =() => result = new AllocationController(true).Index();
It should_display_the_page =() => result.ShouldBeAView();
Cleanup nh =() => NHTestHelper.EndTest(); //need for all tests
static ActionResult result;
}
太棒了,謝謝! – Alistair 2011-05-06 03:55:09
好傑森 - 老闆! – TWright 2013-08-13 20:22:18
@Alistair:這不是針對_each_測試執行的,而是針對所有人執行的。 – Matthias 2015-07-13 11:40:08