Test Annotations — Part 2

In the last article we discuss how to use some test annotations. Let’s go forward and discuss a mechanism to control execution order.

Set priority

We can simply set priorities for the @Test methods as follows.

When we run this the output will be as follows.

o Login

o Create

o Edit

o Delete

o Logout

Default Priority

Here I have removed priority of testLogout() method. When we run this the output order is as follows.

o Login

o Logout

o Create

o Edit

o Delete

When the priority is not given that is default priority and it’s priority=0.

Here, setting priority will be difficult on maintainability when there are more @Test methods. And also here according to the above example pass rete is 40% while failure rate is 60%. As a solution for this difficulty to setting priorities let’s find another method that we can achieve the execution order.

Hope you got clear understanding on how to set priorities in TestNG. See you in another article. Happy learning!!!

Hirudini Udugama

--

--