2017-01-19 5 views
0

私のJavaアプリケーションで統合テストを実行しています。ここ非同期でmvn統合テストを実行する

は私のコードです:ここ

public class MyClassIT { 

@Before 
public void setUp() throws Exception { 
    setUp(); 
} 

@Test 
public void test1() throws Exception { 
    doTheIntegration(1); 
} 

@Test 
public void test2() throws Exception { 
    doTheIntegration(2); 
} 

@Test 
public void test3() throws Exception { 
    doTheIntegration(3); 
} 

private static void doTheIntegration(int i) { 
    System.out.println("started--" + i); 
    doSomethingLongerThan1Minute(); 
    System.out.println("done--" + i); 
} 


@After 
public void tearDown() throws Exception { 
    tearDown(); 

} 

} 

はポンポンフェイルセーフプラグインです:

 <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-failsafe-plugin</artifactId> 
      <version>2.19.1</version> 
      <configuration> 
       <parallel>methods</parallel> 
       <threadCount>10</threadCount> 
      </configuration> 
      <executions> 
       <execution> 
        <id>integration-test</id> 
        <goals> 
         <goal>integration-test</goal> 
        </goals> 
       </execution> 
       <execution> 
        <id>verify</id> 
        <goals> 
         <goal>verify</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 

私はmvn verifyを実行し、すべての3つのテストが 非同期(async)が起こることを期待したが、彼らは同期

で実行されています
$ mvn verify 
------------------------------------------------------- 
T E S T S 
------------------------------------------------------- 
Running com.example.MyClassIT 

started--1 
done--1 
started--2 
done--2 
started--3 
done--3 

どうすれば非同期にすることができますか?

答えて

0

以降のJUnit 4.7からdocsによると、あなたは必ずJUnitの依存関係が正しいバージョン

<dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>4.7</version> 
    </dependency> 
に設定されていることを確認し、平行

でテストを実行することができます