在eclipse中運行集成測試時,我得到了相同的空指針異常。當我在命令提示符下運行相同的測試時,測試正在傳遞。以前測試也在eclipse中傳遞,但是現在我得到的問題在eclipse中運行集成測試時出現空指針異常
錯誤是::
java.lang.NullPointerException
at java.io.FileInputStream.<init>(FileInputStream.java:103)
at java.io.FileInputStream.<init>(FileInputStream.java:66)
at java.io.FileReader.<init>(FileReader.java:41)
at com.cmates.AbstractDBUnitSupport.getReader(AbstractDBUnitSupport.java:465)
at com.cmates.AbstractDBUnitSupport.executeSqlFile(AbstractDBUnitSupport.java:329)
at com.cmates.authorization.RegistrantProvisionsServiceImplIntTest.dropTables(RegistrantProvisionsServiceImplIntTest.java:96)
at com.cmates.authorization.RegistrantProvisionsServiceImplIntTest.tearDown(RegistrantProvisionsServiceImplIntTest.java:105)
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)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:37)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
下次問自己這個問題:「當我沒有向他們展示代碼時,其他人如何告訴我我的代碼有什麼問題」 – Bozho 2010-12-06 09:12:57
我認爲問題不在代碼中。測試用例在我運行時傳遞想到命令提示符。我想我在設置eclipse時遇到了一些問題。只有當我直接從eclipse運行時,測試用例纔會失敗。 – 2010-12-06 09:17:34