Skip to content
Advertisement

How to specify order of execution of Java classes in a Selenium-Java Webdriver test project

I have to automate a test-suite for a web application which let user connect and sync with their Dropbox account. I am using Java Selenium Webdriver.

Here I have created test classes like this.

Class1.java – Test case to check if connected to Internet.

Class2.java- Test case for sign in with Dropbox

Class3.java- Test case to verify if Dropbox folders are shown on web page.

Now these test classes are supposed to execute in this order.

But when I run the project as JUnit test, it executes these tests in some other order. I don’t find any XML file so that I can specify order of execution of these classes.

I also have tried TestNG because I read Here that TestNG provides an attribute “preserve-order”.

But It is not working. I don’t have much experience with Selenium and Java Webdriver.

So any help would be appreciable.

Thanx in advance.

Advertisement

Answer

You can use a JUnit test suite:

import org.junit.RunWith;
import org.junit.runners.Suite;

@RunWith(Suite.class)
@Suite.SuiteClasses({Class1.class, Class2.class, Class3.class})
public class DropboxWorkflow {}
Advertisement