Reputation: 107
i am developing a mocha automation framework. in that there are two hooks beforeEach() and afterEach() which will executed for each test case. i have defined the test setup and cleanup in these hooks. but i have different setup and cleanup for each test case, so i cant able to use beforeEach() and afterEach().
describe()
{
beforeEach(setup) //test setup
it(Test1)
it(Test2)
it(Test3)
afterEach(cleanup)//test cleanup
}
in the above code, each test follows different setup and cleanup. is there any other hooks or methods which satisfies this condition, i.e. hooks which allows to different setup and cleanup for individual test case?
Upvotes: 0
Views: 417
Reputation: 2579
If setup and cleanup are truly different for each test, you should just do something like this:
function test1() {
# Setup
test1SetUp();
# Execute code under test
# Cleanup
test1CleanUp();
}
Do you see (or have already encountered) any issues with that?
Upvotes: 1