Maven错误消息不链接到代码

时间:2014-04-29 17:36:36

标签: eclipse unit-testing maven build compiler-errors

我查看了Google guice库,并将这些项目作为Maclipse项目导入了eclipse Kepler。一切顺利。

当我运行Run As> Maven测试

一次测试失败

Failed tests: 
  testInterceptingNonBridgeWorks(com.google.inject.MethodInterceptionTest).

And the link points to a text file that opens in the editor contains a bunch of exception messages such as 

-------------------------------------------------------------------------------
Test set: com.google.inject.MethodInterceptionTest
-------------------------------------------------------------------------------
Tests run: 10, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.043 sec <<< FAILURE!
testInterceptingNonBridgeWorks(com.google.inject.MethodInterceptionTest)  Time elapsed: 0.01 sec  <<< FAILURE!
junit.framework.AssertionFailedError: expected:<1> but was:<0>
    at junit.framework.Assert.fail(Assert.java:57)
    at junit.framework.Assert.failNotEquals(Assert.java:329)
    at junit.framework.Assert.assertEquals(Assert.java:78)
    at junit.framework.Assert.assertEquals(Assert.java:234)
    at junit.framework.Assert.assertEquals(Assert.java:241)
    at junit.framework.TestCase.assertEquals(TestCase.java:409)
    at com.google.inject.MethodInterceptionTest.testInterceptingNonBridgeWorks(MethodInterceptionTest.java:271)
    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 junit.framework.TestCase.runTest(TestCase.java:176)
    at junit.framework.TestCase.runBare(TestCase.java:141)
    at junit.framework.TestResult$1.protect(TestResult.java:122)
    at junit.framework.TestResult.runProtected(TestResult.java:142)
    at junit.framework.TestResult.run(TestResult.java:125)
    at junit.framework.TestCase.run(TestCase.java:129)
    at junit.framework.TestSuite.runTest(TestSuite.java:255)
    at junit.framework.TestSuite.run(TestSuite.java:250)
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
    at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:59)
    at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:115)
    at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:102)
    at org.apache.maven.surefire.Surefire.run(Surefire.java:180)
    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.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:350)
    at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1021)

我的问题是 - 有没有办法让这样的构建错误直接链接到maven项目中的代码行号,就像普通的Java自然项目一样?

Debasish

1 个答案:

答案 0 :(得分:0)

在eclipse中,只需运行junit测试,您就可以在JUnit窗格中获得适当的支持。否则,从故障堆栈跟踪追溯,您可以轻松地看到它失败的位置:

at com.google.inject.MethodInterceptionTest.testInterceptingNonBridgeWorks(MethodInterceptionTest.java:271)

使用ctrl-shift-T打开文件 - > MIT

使用ctrl-L定位错误 - &gt; 271