Test Annotations — Part 3

Setting Dependency

We can set dependencies instead of setting priority as follows. By assigning dependencies we can define which methods should run before to a particular method.

Output will be as follows.

o Login

o Create

o Edit

o Delete

o Logout

How to run multiple test classes?

Right click on the selected → Run → Run 1 and 4 more

How to run multiple test classes in a single file?

We use test suite to accomplish this task. To do that you can simply go to root directory right click → New → File

We should use .xml extension for the test suite. Let us create it as TestSuite.xml

We can copy testing.xml

Search for testing.xml by https://testng.org/doc/documentation-main.html#testng-xml

Then let us paste it in TestSuite.xml file and do some modifications.

Now you can run multiple test classes that are in a single file.

We are done with setting dependency with test annotations. See you in another article. Happy learning!!!

Hirudini Udugama

--

--