mardi 31 mai 2016

Testing multithread when I thow it with maven it.test

I want execute simultaneously all test'methods.

¿It's possible do it from maven when I'm throwing the test using -Dit.test=myTestSuite?

I am trying it, but the test is always executed from the same treahd.

The maven line I use

mvn verify surefire:test -Dit.test=JMOMTestSuite

Part of my pom.xml

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.19.1</version>
        <configuration>
            <forkCount>5</forkCount>
            <parallel>methods</parallel>
            <reuseForks>false</reuseForks>
        </configuration>
      </plugin>

My testSuite

package tsol.mentes.tester.suites;

import org.junit.runners.Suite.SuiteClasses;

import tsol.mentes.tester.JMOMTest;

@SuiteClasses({ JMOMTest.class })
public class JMOMTestSuite extends AbstractTestSuite {
    // the tests classes are executed in the order they are included in the
    // SuiteClasses annotation

}

My test

package tsol.mentes.tester;

import org.apache.commons.logging.LogFactory;
import org.junit.Test;

public class JMOMTest extends AbstractTest {

    static {
        log = LogFactory.getLog(JMOMTest.class);
    }

    @Override
    public void setUp() {
        super.setUp();
        System.out.println();
    }

    @Test
    public void testPrueba1() throws Exception {
        System.out.println(Thread.currentThread().getName() + " -> Test prueba 1");
    }

    @Test
    public void testPrueba2() throws Exception {
        System.out.println(Thread.currentThread().getName() + " -> Test prueba 2");
    }

    @Test
    public void testPrueba3() throws Exception {
        System.out.println(Thread.currentThread().getName() + " -> Test prueba 3");
    }

    @Test
    public void testPrueba4() throws Exception {
        System.out.println(Thread.currentThread().getName() + " -> Test prueba 4");
    }

    @Test
    public void testPrueba5() throws Exception {
        System.out.println(Thread.currentThread().getName() + " -> Test prueba 5");
    }

    @Test
    public void testPrueba6() throws Exception {
        System.out.println(Thread.currentThread().getName() + " -> Test prueba 6");
    }

    @Test
    public void testPrueba7() throws Exception {
        System.out.println(Thread.currentThread().getName() + " -> Test prueba 7");
    }

    @Test
    public void testPrueba8() throws Exception {
        System.out.println(Thread.currentThread().getName() + " -> Test prueba 8");
    }

    @Test
    public void testPrueba9() throws Exception {
        System.out.println(Thread.currentThread().getName() + " -> Test prueba 9");
    }

    @Test
    public void testPrueba10() throws Exception {
        System.out.println(Thread.currentThread().getName() + " -> Test prueba 10");
    }

    @Test
    public void testPrueba11() throws Exception {
        System.out.println(Thread.currentThread().getName() + " -> Test prueba 11");
    }

    @Test
    public void testPrueba12() throws Exception {
        System.out.println(Thread.currentThread().getName() + " -> Test prueba 12");
    }

    @Test
    public void testPrueba13() throws Exception {
        System.out.println(Thread.currentThread().getName() + " -> Test prueba 13");
    }

    @Test
    public void testPrueba14() throws Exception {
        System.out.println(Thread.currentThread().getName() + " -> Test prueba 14");
    }

    @Test
    public void testPrueba15() throws Exception {
        System.out.println(Thread.currentThread().getName() + " -> Test prueba 15");
    }

    @Test
    public void testPrueba16() throws Exception {
        System.out.println(Thread.currentThread().getName() + " -> Test prueba 16");
    }

    @Test
    public void testPrueba17() throws Exception {
        System.out.println(Thread.currentThread().getName() + " -> Test prueba 17");
    }

    @Test
    public void testPrueba18() throws Exception {
        System.out.println(Thread.currentThread().getName() + " -> Test prueba 18");
    }

    @Test
    public void testPrueba19() throws Exception {
        System.out.println(Thread.currentThread().getName() + " -> Test prueba 19");
    }

    @Test
    public void testPrueba20() throws Exception {
        System.out.println(Thread.currentThread().getName() + " -> Test prueba 20");
    }
}

Aucun commentaire:

Enregistrer un commentaire