Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

Is it possible to specify the test execution order with Silk4J?

Is it possible to specify the test execution order with Silk4J?

The default execution order of execution of JUnit tests is not predictable.  This is as designed for JUnit.  It is recommended that tests be written so that they are independent of the order that they are executed.

However from JUnit 4.11 onwards you can set the execution order using the @FixMethodOrder annotation.
For Example:-
@FixMethodOrder(MethodSorters.NAME_ASCENDING)

The MethodSorter values are DEFAULT, JVM and NAME_ASCENDING. So you could guarantee the order of your tests by using a naming convention.

Please see example below that will sort your execution order by name:-

import org.junit.FixMethodOrder;
import org.junit.runners.MethodSorters;
import org.junit.Test;


@FixMethodOrder(MethodSorters.NAME_ASCENDING)

public class TestOrder {

    @Test
    public void b() {
        System.out.println("test b");
    }

    @Test
    public void a(){
        System.out.println("test a");
    }
    
    @Test
        public void d() {
            System.out.println("test d");
    }

    @Test
    public void c() {
        System.out.println("test c");
}
    
}

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2014-10-10 14:42
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.