我有這樣的配置:爲什麼maven surefire會嘗試實例化其他組的測試?
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.13</version>
<configuration>
<excludedGroups>integration</excludedGroups>
<argLine>-Xmx512m -XX:MaxPermSize=128m</argLine>
<systemPropertyVariables>
<project.build.directory>${project.build.directory}</project.build.directory>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
和測試:
@Test(groups = "integration")//testng
public class MyTest extends BaseTestForMyTest {
private final SomeClass sut = new SomeClass(getStuffFromSysPropDefinedForFailSafe());//should fail in surefire.
@Test(groups = "integration")
public void someTest() throws IOException {
//some code
}
}
萬無一失嘗試實例化一個類和失敗(失敗是確定的,該試驗對故障安全!)。 爲什麼,surefire爲什麼試圖從排除的組中實例化測試?
對不起,我沒有提到。我正在使用testng
我沒有注意到代碼窗口有一個滾動條,完全錯過了代碼中的註釋!我已經用我認爲是更合適的答案更新了我的答案。我留下了最初的答案,儘管他們並不嚴格回答你問的問題。 –
另外:如果此測試是針對故障安全插件的,那麼您應該將它從絕對執行中排除。最簡單的方法(根據maven關於配置的約定的想法)是將你的類從MyTest重命名爲MyIT。或者,將它添加到surefire的執行配置中。 –