Automate Test Scenario Life Cycle

Piyathida San-aoun
2 min readJul 25, 2020

Today I want to share how to we arrange life cycle when we would like to create automate test

I will explain from the project I have been implementing. Let’s go!!!

The picture above, It’s overall of scenario life cycle we will small talk about the detail each level

  1. BeforeTestRun + AfterTestRun

The first level or level zero, we will put method TestStartUp on here should and ensure for beforeTestRun should be static class only. and why is the reason might be the engine limitation but having these methods as static effectively denies all dependency-injection options at this point? but I’m not sure 100%. If you guys have true reason let’s me know!!

2. BeforeFeature + AfterFeature

On the second level, We will implement Authorization or Create Http client on her. Might be created APISessionMenage class and call in this level. For this level is the same as BeforeTestRun should be static class only as well.

I create Authorization or Create Http client on her because every time we run test should ensure we can authen token. For example, if you could imagine when you test API on postman. We will prepare authen token first and ensure your user ID can access.

3.BeforeScenario + AfterScenario

The last level, BeforeScenario I will provisioning data and clear data on this level. I was just trying to say that it makes sense to clear database and clear Azure storage(on cloud) before each scenario, not before feature. Since you have two scenarios in this feature, the second scenario will get “dirty” application state. but also this can be more faster, especially on large db.

Finally, This blog I would like to share my experienced. If a reader has comments or give feedback please feel free to do. I’m not professional of automate engineer but should not be wait to be perfect just to do and learn together.

Have fun with Automate test!!

--

--