Arquillian/JUnit 测试从控制台运行,但不在 Eclipse 内运行
我已经使用一些 JUnit 测试设置了我们的项目,这些测试由 Arquillian 在完整的 JBoss 服务器内(在名为 jboss-remote-6 的配置文件内)运行。我几乎按照 http:// /docs.jboss.org/arquillian/reference/latest/en-US/html/gettingstarted.html。
如果我在控制台中执行mvn test
,则一切都会正确执行并检查断言。
但是,当我尝试在 Eclipse 中运行 JUnit 测试用例时,它失败并出现以下异常:
org.jboss.arquillian.impl.client.deployment.ValidationException: DeploymentScenario contains targets not maching any defined Container in the registry. _DEFAULT_
at org.jboss.arquillian.impl.client.deployment.DeploymentGenerator.validate(DeploymentGenerator.java:95)
at org.jboss.arquillian.impl.client.deployment.DeploymentGenerator.generateDeployment(DeploymentGenerator.java:77)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
(...)
我将此项目的 Maven 配置文件正确设置为“jbossas-remote-6”,如 pom.xml 中所述。我做错了什么? Google 无法针对这一具体问题提供帮助。
此致, 塞巴斯蒂安
I've setup our project with some JUnit tests that are run by Arquillian inside the full JBoss Server (inside a profile called jboss-remote-6). I pretty much did everything as in the manual at http://docs.jboss.org/arquillian/reference/latest/en-US/html/gettingstarted.html.
If I execute mvn test
in the console, everything is properly executed and the assertions are checked.
But when I try to run the JUnit test case inside Eclipse, it fails with the following exception:
org.jboss.arquillian.impl.client.deployment.ValidationException: DeploymentScenario contains targets not maching any defined Container in the registry. _DEFAULT_
at org.jboss.arquillian.impl.client.deployment.DeploymentGenerator.validate(DeploymentGenerator.java:95)
at org.jboss.arquillian.impl.client.deployment.DeploymentGenerator.generateDeployment(DeploymentGenerator.java:77)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
(...)
I set up the Maven profile for this project correctly to "jbossas-remote-6" as stated in the pom.xml. What am I doing wrong? Google coulnd't help on this specific one.
Best regards,
Sebastian
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为了使这项工作成功,我做了很多事情。我的角色模型是 jboss-javaee6 Maven 原型,它也使用 Arquillian 在远程 JBoss 6 服务器中对代码进行单元测试。我执行了以下步骤:
添加 arquillian.xml
我在 src/test/resources 中添加了 Arquillian.xml:
Shrinkwrap WebArchive 而不是 JavaArchive
使用
return Shrinkwrap。 create(WebArchive.class, "test.war")
而不是JavaArchive.class
创建了该方法可用的addAsWebInfResource()
方法,我可以在其中添加空的生成的 beans.xml。调整 pom.xml 以减少 CLASSPATH 长度
Eclipse 不断出现 javaw.exe 中断,并给出 CreateProcess error=87 消息。这是由于 CLASSPATH 对于控制台命令来说太长造成的。由于依赖项jboss-as-client添加了无数的依赖项,我将其更改为jboss-as-profileservice-client,它工作正常并且依赖项少得多。
另一件重要的事情是在 src/test/resources 目录中有一个 jndi.properties 文件,如 Arquillian 文档中所述。但这里已经是这种情况了。我猜 arquillian.xml 造成了差异 - 该文件从未在文档中提及,只是在原型中看到它。
这是我用于远程 JBoss 测试的 Maven 配置文件:
我希望我的回答对某人有用。 :)
There are various things I did to make this work. My role model was the jboss-javaee6 Maven archetype, which is also using Arquillian for unit testing the code in a remote JBoss 6 server. I did the following steps:
Add arquillian.xml
I added the Arquillian.xml in src/test/resources:
Shrinkwrap a WebArchive instead of JavaArchive
Using
return Shrinkwrap.create( WebArchive.class, "test.war")
instead of theJavaArchive.class
made the methodaddAsWebInfResource()
method available, where I could add the empty generated beans.xml.Adjust pom.xml to reduce CLASSPATH length
Eclipse was constantly breaking with javaw.exe giving a CreateProcess error=87 message. This was caused by the CLASSPATH being too long for the console command. Since the dependency jboss-as-client added Bazillions of dependencies, I changed it to jboss-as-profileservice-client which works fine and has a lot less dependencies.
Another important thing is to have a jndi.properties file in the src/test/resources directory, as stated in the Arquillian docs. But that was already the case here. I guess the arquillian.xml made the difference - this file was never mentioned in the docs, just saw it in the archetype.
This is my Maven profile for remote JBoss testing:
I hope my answer will be useful to somebody. :)
请注意,还有一个与在 Eclipse 中运行测试相关的未解决问题:
https://issues .jboss.org/browse/ARQ-1037?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
Note there is also an open issue related to running tests in Eclipse:
https://issues.jboss.org/browse/ARQ-1037?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel