我有用于设置和拆除 NHibernate 的通用代码,我几乎所有的测试都需要它。有没有办法将“需要所有测试”代码包含在一个地方,然后将其应用于所有测试?(即像 Nunit 的setup
和teardown
方法)
[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;
}