当我配置maven surefire插件使用
打印完整的堆栈跟踪时<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.15</version>
<configuration>
<trimStackTrace>false</trimStackTrace>
<failOnMissingWebXml>false</failOnMissingWebXml>
<useFile>false</useFile>
<redirectTestOutputToFile>false</redirectTestOutputToFile>
</configuration>
</plugin>
它似乎不会影响嵌套堆栈,因为它们仍然被剪切,例如:
org.apache.openejb.OpenEjbContainer$AssembleApplicationException: org.apache.openejb.OpenEJBException: Creating application failed: /mnt/DATA/richter/NetBeansProjects/issue-openwebbeans: couldn't start owb context
at org.apache.openejb.OpenEjbContainer$Provider.createEJBContainer(OpenEjbContainer.java:427)
at javax.ejb.embeddable.EJBContainer.createEJBContainer(EJBContainer.java:56)
at de.pgalise.issue.openwebbeans.TestUtils.getContainer(TestUtils.java:50)
at de.pgalise.issue.openwebbeans.CityCtrlTest.setUp(CityCtrlTest.java:27)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
Caused by: org.apache.openejb.OpenEJBException: Creating application failed: /mnt/DATA/richter/NetBeansProjects/issue-openwebbeans: couldn't start owb context
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:901)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:616)
at org.apache.openejb.OpenEjbContainer$Provider.createEJBContainer(OpenEjbContainer.java:423)
... 20 more
Caused by: org.apache.openejb.OpenEJBRuntimeException: couldn't start owb context
at org.apache.openejb.cdi.ThreadSingletonServiceImpl.initialize(ThreadSingletonServiceImpl.java:161)
at org.apache.openejb.cdi.CdiBuilder.build(CdiBuilder.java:40)
at org.apache.openejb.assembler.classic.Assembler.createApplication(Assembler.java:803)
... 22 more
Caused by: org.apache.openejb.OpenEJBRuntimeException: javax.enterprise.event.ObserverException: Caught Exception while handling event object with type : org.apache.webbeans.portable.events.discovery.AfterBeanDiscoveryImpl
at org.apache.openejb.cdi.OpenEJBLifecycle.startApplication(OpenEJBLifecycle.java:187)
at org.apache.openejb.cdi.ThreadSingletonServiceImpl.initialize(ThreadSingletonServiceImpl.java:159)
... 24 more
Caused by: javax.enterprise.event.ObserverException: Caught Exception while handling event object with type : org.apache.webbeans.portable.events.discovery.AfterBeanDiscoveryImpl
at org.apache.webbeans.event.NotificationManager.fireEvent(NotificationManager.java:501)
at org.apache.webbeans.container.BeanManagerImpl.fireEvent(BeanManagerImpl.java:446)
at org.apache.webbeans.container.BeanManagerImpl.fireLifecycleEvent(BeanManagerImpl.java:436)
at org.apache.webbeans.config.BeansDeployer.fireAfterBeanDiscoveryEvent(BeansDeployer.java:362)
at org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:199)
at org.apache.openejb.cdi.OpenEJBLifecycle.startApplication(OpenEJBLifecycle.java:184)
... 25 more
Caused by: org.apache.webbeans.exception.WebBeansException: java.lang.reflect.InvocationTargetException
at org.apache.webbeans.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:272)
at org.apache.webbeans.event.NotificationManager.fireEvent(NotificationManager.java:482)
... 30 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.webbeans.event.ObserverMethodImpl.notify(ObserverMethodImpl.java:266)
... 31 more
Caused by: java.lang.NoSuchMethodError: javax.enterprise.inject.spi.BeanManager.getInjectionTargetFactory(Ljavax/enterprise/inject/spi/AnnotatedType;)Ljavax/enterprise/inject/spi/InjectionTargetFactory;
at com.sun.faces.util.cdi11.CDIUtilImpl.createHelperBean(CDIUtilImpl.java:76)
at com.sun.faces.application.view.ViewScopeExtension.afterBeanDiscovery(ViewScopeExtension.java:130)
... 36 more
我假设 trimStackTrace 的文档“是否将报告中的堆栈跟踪修剪为仅测试中的行,或显示完整的跟踪。”是不够的,因为它不会在堆栈和嵌套堆栈之间做出任何区分。是否有可能控制两者?
答案 0 :(得分:2)
我猜你已经看到了完整的堆栈跟踪;)关于&#34; ... 24更多&#34;您提供的样本中的模式,我不知道,也不认为您可以获得它们。
关于warfire配置&#34; trimStackTrace&#34;的角色,以及您认为无效的内容。属性,我挣扎了一段时间,不明白为什么我从IntelliJ运行测试时看到异常根本原因,但是从maven命令行运行时却没有。在这里,您将看到该属性对于启用异常根本原因的显示非常有效。
没有&#34; trimStackTrace&#34; (默认:false)surefire配置属性,我有这个输出:
2014-03-27 19:29:30,933 [main] DEBUG o.h.c.annotations.SimpleValueBinder - Starting fillSimpleValue for lastFetchTime 2014-03-27 19:29:30,933 [main] DEBUG org.hibernate.cfg.Configuration - Processing fk mappings (*ToOne and JoinedSubclass) Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 5.032 sec (StorageHelper.java:35) at com.company.foobar.helper.StorageHelper.getInstance(StorageHelper.java:26) at com.company.foobar.StorageHelperTest.foo(StorageHelperTest.java:40) 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:483) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:254) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:149) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124) at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103) Results : Tests in error: StorageHelperTest.foo:40 » Persistence [PersistenceUnit: default-persistence-u...
设置&#34; trimStackTrace&#34; property,on&#34; true&#34;,我现在得到例外根本原因:
2014-03-27 19:29:30,933 [main] DEBUG o.h.c.annotations.SimpleValueBinder - Starting fillSimpleValue for lastFetchTime 2014-03-27 19:29:30,933 [main] DEBUG org.hibernate.cfg.Configuration - Processing fk mappings (*ToOne and JoinedSubclass) Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 5.032 sec (StorageHelper.java:35) at com.company.foobar.helper.StorageHelper.getInstance(StorageHelper.java:26) at com.company.foobar.StorageHelperTest.foo(StorageHelperTest.java:40) 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:483) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:254) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:149) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:124) at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:200) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:153) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103) Caused by: org.hibernate.AnnotationException: A Foreign key refering com.company.foobar.bean.FooBarItemCriterias from com.company.foobar.bean.FooBarOpportunity has the wrong number of column. should be 22 at org.hibernate.cfg.annotations.TableBinder.bindFk(TableBinder.java:450) at org.hibernate.cfg.ToOneFkSecondPass.doSecondPass(ToOneFkSecondPass.java:117) at org.hibernate.cfg.Configuration.processEndOfQueue(Configuration.java:1596) at org.hibernate.cfg.Configuration.processFkSecondPassInOrder(Configuration.java:1519) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1420) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1844) at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl$4.perform(EntityManagerFactoryBuilderImpl.java:850) ... 36 more Results : Tests in error: StorageHelperTest.foo:40 » Persistence [PersistenceUnit: default-persistence-u...
顺便说一句,此选项记录为&#34;是否将报告中的堆栈跟踪修剪为仅测试中的行,或显示完整的跟踪&#34;这是模棱两可的。起初,我想&#34;报告&#34;只有你可以在&#34; $ {basedir} / target / surefire-reports /&#34;中找到的XML和文本文件,但它主要指定surefire控制台输出,以及扩展名的那些文件。