How to sequentially execute test method

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

How to sequentially execute test method

vijayk
Hello I've three methods doTransaction1(), doTransaction2() and doTransaction3().

i need to execute 50% Transaction1, 20% Transaction2 and 30% Transaction3.
Order of execution is Transaction1 -> Transaction2-> Transaction3
If Transaction2 or Transaction3 execute before Transaction1 then they'll fail.

While execution i'm not able to control sequence Transaction,  hence Transaction2 and Transaction3 are failing as Transaction1 is executing at last;

Below is my code :



@RunWith(GrinderRunner)
class TestRunner {
        public static HTTPRequest request
    static GTest test1
    static GTest test2
    static GTest test3
    @BeforeProcess
    public static void beforeProcess() {
        test1 = new GTest(1,"test1_statistics")
        test2 = new GTest(2,"test2_statistics")
        test3 = new GTest(3,"test3_statistics")
        request = new HTTPRequest();
        HTTPPluginControl.getConnectionDefaults().timeout = 6000
        grinder.logger.info("before process.");
    }

    @BeforeThread
    public void beforeThread() {
        test1.record(this, "doTransaction1"); // Record current object’s doTransaction1 method into test1.
        test2.record(this, "doTransaction2"); // Record current object’s doTransaction2 method into test2.
        test3.record(this, "doTransaction3"); // Record current object’s doTransaction3 method into test3
        grinder.statistics.delayReports=true;
        grinder.logger.info("before thread.");
    }
        @RunRate(50)
    @Test
    public void doTransaction1(){
        // Do transactions here!!
                grinder.logger.info("one");
    }
        @RunRate(20)
    @Test
    public void doTransaction2(){
        // Do another transactions here!!
                grinder.logger.info("two");
    }
        @RunRate(30)
        @Test
    public void doTransaction3(){
        // Do another transactions here!!
                grinder.logger.info("three");
    }
}

------------------------------------------------------Output------------------------------

2019-01-02 12:39:08,564 INFO  net.grinder.engine.process.JUnitThreadContextInitializer: two
2019-01-02 12:39:08,566 INFO  net.grinder.engine.process.JUnitThreadContextInitializer: one
2019-01-02 12:39:08,568 INFO  net.grinder.engine.process.JUnitThreadContextInitializer: three