我有几个标准的junit集成测试与阿奎利安,tomcat7嵌入式tomcat7:7.0.50)和Shrinkwrap。
@RunWith(Arquillian.class)
public class TestMe {
@Deployment
public static WebArchive deploy() {
return
ShrinkWrap.create(WebArchive.class, "test.war")
.addPackages(true, "org.foo")
.addAsManifestResource("META-INF/context.xml", "context.xml")
.addAsWebInfResource("WEB-INF/beans.xml", "beans.xml")
.addAsWebInfResource("WEB-INF/web.xml", "web.xml").as(WebArchive.class);
}
@Test ...
}
单独通过maven执行,每个测试都是绿色的。但是如果我做了一个mvn,验证并启动整个测试套件:java.net.BindException: Address已经在使用: JVM_Bind :9095。有什么问题吗?
arquillian.xml:
<arquillian xmlns="http://jboss.org/schema/arquillian"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<defaultProtocol type="Servlet 3.0" />
<engine>
<property name="deploymentExportPath">target</property>
</engine>
<container qualifier="tomcat" default="true">
<configuration>
<property name="unpackArchive">true</property>
<property name="bindAddress">localhost</property>
<property name="bindHttpPort">9095</property>
<property name="serverName">amgui-arquillian-tomcat7-embedded</property>
</configuration>
</container>
发布于 2015-02-03 10:11:28
看起来mvn验证正在尝试并行运行测试。或者至少不要等到上一个测试在开始下一个测试之前清理掉。不能有多个进程绑定到同一个地址/端口组合。
Tomcat连接器支持每次开始使用新的自由端口的概念,以避免此类问题(将端口设置为零),但我不认为它本身会对您有所帮助。您的测试环境需要知道查询Tomcat以找出每个测试使用哪个端口。
我会尝试修改你的测试,这样它们就不会并行运行。
https://stackoverflow.com/questions/28238774
复制相似问题