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

Tags: , , , ,

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. – Test case to check if connected to Internet. Test case for sign in with Dropbox 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.


You can use a JUnit test suite:

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

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

Source: stackoverflow