2010-12-06 41 views
0

在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) 
+3

下次问自己这个问题:“当我没有向他们展示代码时,其他人如何告诉我我的代码有什么问题” – Bozho 2010-12-06 09:12:57

+0

我认为问题不在代码中。测试用例在我运行时传递想到命令提示符。我想我在设置eclipse时遇到了一些问题。只有当我直接从eclipse运行时,测试用例才会失败。 – 2010-12-06 09:17:34

回答

0

FileInputStream构造函数抛出一个NullPointerException如果File参数null。这就是你必须开始搜索的地方。也许你想读取一个无法从“测试环境”解决的SQL文件。

0

方法RegistrantProvisionsServiceImplIntTest.dropTables()正试图执行一个SQL文件,但找不到它。您可能需要在eclipse中刷新项目。这也可能是访问权限的问题。

0

您正在尝试使用不正确初始化的数据库连接。

您确定在JUnit中正确使用“Setup + teardown”工具吗?