在eclipse中运行集成测试时出现空指针异常

时间:2010-12-06 09:11:27

标签: java

我在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 个答案:

答案 0 :(得分:0)

如果FileInputStream参数为NullPointerException,则File的构造函数会抛出null。那是你必须开始搜索的地方。也许您想要读取无法从“测试环境”中解析的sql文件。

答案 1 :(得分:0)

方法RegistrantProvisionsServiceImplIntTest.dropTables()正在尝试执行SQL文件但无法找到它。您可能必须在eclipse中刷新项目。它也可能是访问权限的问题。

答案 2 :(得分:0)

您正尝试使用错误初始化的数据库连接。

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

相关问题