【发布时间】:2021-03-15 06:13:36
【问题描述】:
我已将surefire "trimStackTrace" 更改为 false 以获取测试失败的完整堆栈跟踪,但生成的报告仅包含某些测试的堆栈跟踪。我使用junit 4.12和maven surefire“3.0.0-M5”。例如,对于同一个类(包 cc.mallet)中的两个测试,我得到这两个结果如下。在测试 13 中,我有完整的跟踪,但对于测试 16,我没有。是否可以在生成的肯定报告中包含失败测试的完整堆栈跟踪? 测试 13:
java.lang.AssertionError
**at cc.mallet.types.FeatureSequence.add(FeatureSequence.java:129)
at cc.mallet.types.FeatureSequence.<init>(FeatureSequence.java:48)**
at cc.mallet.types.HashedSparseVector_ESTest.test13(HashedSparseVector_ESTest.java:559)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:288)
at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:282)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.lang.Thread.run(Thread.java:748)
''' 测试 16: '''
java.lang.AssertionError: expected:<1.0> but was:<1825.52014>
at org.junit.Assert.fail(Assert.java:89)
at org.junit.Assert.failNotEquals(Assert.java:835)
at org.junit.Assert.assertEquals(Assert.java:555)
at org.junit.Assert.assertEquals(Assert.java:685)
at cc.mallet.types.HashedSparseVector_ESTest.test16(HashedSparseVector_ESTest.java:735)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:288)
at org.junit.internal.runners.statements.FailOnTimeout$CallableStatement.call(FailOnTimeout.java:282)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.lang.Thread.run(Thread.java:748)
'''
【问题讨论】:
标签: maven unit-testing stack-trace maven-surefire-plugin