嗨,我正在使用Windows XP和最新版本在这里完成教程
http://binil.wordpress.com/2006/12/08/automated-smoke-tests-with-selenium-cargo-testng-and-maven/
有人可以告诉我标签是什么.
<parallel>true</parallel>
<threadCount>10</threadCount>
Run Code Online (Sandbox Code Playgroud)
当我使用这些标签构建时,我遇到了失败:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
org.apache.maven.surefire.booter.SurefireExecutionException:
Cannot set option parallel with value
true; nested exception is
java.lang.reflect.InvocationTargetException:
null; nested exception is
org.apache.maven.surefire.util.NestedRuntimeException:
Cannot set option parallel with value
true; nested exception is
java.lang.reflect.InvocationTargetException:
null
org.apache.maven.surefire.util.NestedRuntimeException:
Cannot set option parallel with value
true; nested exception is
java.lang.reflect.InvocationTargetException:
null
java.lang.reflect.InvocationTargetException
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:585)
at
org.apache.maven.surefire.testng.conf.AbstractDirectConfigurator$Setter.invoke(AbstractDirectConfigurator.java:117)
at
org.apache.maven.surefire.testng.conf.AbstractDirectConfigurator.configure(AbstractDirectConfigurator.java:63)
at
org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:71)
at
org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:92)
at
org.apache.maven.surefire.Surefire.run(Surefire.java:177)
at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native …Run Code Online (Sandbox Code Playgroud) 我的问题:当从Test Suite执行此类时,是否有办法强制Maven Surefire(或JUnit?)指示失败的测试类的名称?
现在,漫长的故事.
想象一下,你有一个JUnit测试套件,可以启动两个JUnit测试.
测试类的示例:
public class TestOne {
@Test
public void foo() {
assertTrue(false);
}
@Test
public void bar() {
assertTrue(false);
}
}
@UnitTest
public class TestTwo {
@Test
public void foo() {
assertFalse(true);
}
}
Run Code Online (Sandbox Code Playgroud)
和测试套件:
@RunWith(Suite.class)
@SuiteClasses(value = { TestOne.class, TestTwo.class })
public class MySuite {
}
Run Code Online (Sandbox Code Playgroud)
现在,如果我运行测试套件(mvn test -Dtest=MySuite),我将有以下错误:
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running caf.opm.preclosing.junit.MySuite
Tests run: 3, Failures: 3, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec …Run Code Online (Sandbox Code Playgroud) 当我跑步时,mvn test我收到以下异常.我已尝试升级和降低我的Xmx和Xss JVM设置,并在ulimit下突破所有限制.大约有1300个测试,最后200个测试总是因此异常而失败.自己运行这些测试允许它们通过.相同的测试在我的ubuntu盒子上传递.我在mac上运行测试时收到此异常.我很确定它是一个环境问题,但我已经调整了我所知道的每一个设置,绝对没有运气.
我使用的是mvn 2.1和Java 6.我的测试框架是junit 4.8.
java.lang.OutOfMemoryError: unable to create new native thread
at java.lang.Thread.start0(Native Method)
at java.lang.Thread.start(Thread.java:658)
at java.util.concurrent.ThreadPoolExecutor.addIfUnderMaximumPoolSize(ThreadPoolExecutor.java:727)
at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:657)
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:92)
at com.google.appengine.tools.development.ApiProxyLocalImpl$PrivilegedApiAction.run(ApiProxyLocalImpl.java:197)
at com.google.appengine.tools.development.ApiProxyLocalImpl$PrivilegedApiAction.run(ApiProxyLocalImpl.java:184)
at java.security.AccessController.doPrivileged(Native Method)
at com.google.appengine.tools.development.ApiProxyLocalImpl.doAsyncCall(ApiProxyLocalImpl.java:172)
at com.google.appengine.tools.development.ApiProxyLocalImpl.makeAsyncCall(ApiProxyLocalImpl.java:138)
Run Code Online (Sandbox Code Playgroud) 假设Maven Surefire插件默认顺序执行测试用例是否合理:测试用例在下一个测试用例开始之前结束(我对顺序不感兴趣).我发现你可以配置Surefire并行运行,这是否意味着顺序执行是默认行为,将来可能会发生?
注意:如果你问为什么我要强制测试顺序运行(我知道,好的测试应该能够并行运行),这是因为我正在解决一个特定问题的解决方案,涉及到Web应用程序.你可以在这里阅读它.
谢谢
在我的spring + maven应用程序中,我已经为数据访问层创建了一些测试,我现在希望针对多个数据源运行.我有类似的东西:
@ContextConfiguration(locations={"file:src/test/resources/testAppConfigMysql.xml"})
public class TestFooDao extends AbstractTransactionalJUnit38SpringContextTests {
public void testFoo(){
...
}
}
Run Code Online (Sandbox Code Playgroud)
它目前的配置位置是硬编码的,因此它只能用于一个数据源.调用测试两次并传递两个不同配置的最佳方法是什么(比如testAppConfigMysql.xml和testMyConfigHsqlDb.xml)?
我已经看到过通过系统属性执行此操作的建议.如何告诉maven使用不同的系统属性值调用两次测试?
我正在使用Jenkins执行我们的单元测试并向开发人员发送电子邮件.我正在使用Jelly Script在电子邮件中包含通过/未通过结果.但是,我还想在测试构建完成后包含surefire报告呈现给您的通过/失败图.毕竟,这是我们感兴趣的图表,对吧?:)
我的项目有一些JUnit我很少想要运行的测试.为此,我把它们放进去@Category,然后我做了这个:
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<!-- Run all but the inject tests -->
<configuration>
<groups>!be.test.InjectTests</groups>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
我想在命令行中覆盖配置以运行Inject测试,如下所示:
mvn clean install -Dgroups=be.test.InjectTests
Run Code Online (Sandbox Code Playgroud)
但这不起作用,-Dgroups被Maven忽略了.
如果我不把命令工作正常.
Context 我使用Java,JUnit和Selenuim WebDriver实现了一个测试套件,以自动化Web应用程序的测试.Test Suite在Jenkins中部署为Maven作业,可以重建对TestSuite或SUT的更改.Jenkins还运行TestSuite,为测试案例提供了许多顶级maven作业,以便按计划和按需不断地使用不同的浏览器测试目标系统.Surefire插件用于显示测试结果,Emma插件用于测试覆盖率.
当JUnit @Test失败时(即检测到SUT中的错误,而不是测试套件错误),该套件会将浏览器的屏幕截图保存到Jenkins工作区下的文件夹中.屏幕截图文件名是UUID,记录在测试日志中.这一切都非常有效.
问题 通过Jenkins UI钻入工作区可以看到屏幕截图.然而,这是一种笨拙的机制.我想在Jenkins UI中找到一种方法,将Surefire结果和/或控制台输出超链接到特定的屏幕截图.例如,通过单击日志中的UUID.
由于SUREFIRE-938,测试的输出缓冲在 /tmp/stdout*deferred 中以创建 XML 报告。我对 XML 或任何其他形式的报告不感兴趣,但我在测试执行期间收集了千兆字节的日志,并将它们也写入 /tmp。有时缓冲区文件和输出日志的总大小太大,不适合 - 有没有办法禁用报告和所有这些缓冲(这也会减慢测试速度)?