我正在与fitnesse(20140630)+ maven
合作但是当我运行测试时,我会遇到异常:
异常:显示java.lang.NullPointerException 在com.playtech.openapi.core.fitnesse.tests.Fixtures.createContext(Fixtures.java:14)[file:/ D:/FitnesseTests/IntegrationTestsMobileAdmin/com-playtech-openapi-frontend-services/com.playtech.openapi。 core.fitnesse.tests /目标/类/] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[rt.jar:1.7.0_21] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[rt.jar:1.7.0_21] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[rt.jar:1.7.0_21] 在java.lang.reflect.Method.invoke(Method.java:601)[rt.jar:1.7.0_21] at fitnesse.slim.fixtureInteraction.DefaultInteraction.methodInvoke(DefaultInteraction.java:16)[fitnesse-standalone.jar] at fitnesse.slim.MethodExecutor.callMethod(MethodExecutor.java:43)[fitnesse-standalone.jar] at fitnesse.slim.MethodExecutor.invokeMethod(MethodExecutor.java:30)[fitnesse-standalone.jar] at fitnesse.slim.MethodExecutor.findAndInvoke(MethodExecutor.java:52)[fitnesse-standalone.jar] at fitnesse.slim.FixtureMethodExecutor.execute(FixtureMethodExecutor.java:20)[fitnesse-standalone.jar] at fitnesse.slim.StatementExecutor.getMethodExecutionResult(StatementExecutor.java:121)[fitnesse-standalone.jar] at fitnesse.slim.StatementExecutor.callAndAssign(StatementExecutor.java:109)[fitnesse-standalone.jar] at fitnesse.slim.instructions.CallAndAssignInstruction.executeInternal(CallAndAssignInstruction.java:38)[fitnesse-standalone.jar] at fitnesse.slim.instructions.Instruction.execute(Instruction.java:30)[fitnesse-standalone.jar] at fitnesse.slim.ListExecutor $ Executive.executeStatement(ListExecutor.java:50)[fitnesse-standalone.jar] at fitnesse.slim.ListExecutor $ Executive.executeStatements(ListExecutor.java:44)[fitnesse-standalone.jar] at fitnesse.slim.ListExecutor.execute(ListExecutor.java:84)[fitnesse-standalone.jar] at fitnesse.slim.SlimServer.executeInstructions(SlimServer.java:107)[fitnesse-standalone.jar] at fitnesse.slim.SlimServer.processTheInstructions(SlimServer.java:94)[fitnesse-standalone.jar] at fitnesse.slim.SlimServer.processOneSetOfInstructions(SlimServer.java:68)[fitnesse-standalone.jar] at fitnesse.slim.SlimServer.tryProcessInstructions(SlimServer.java:54)[fitnesse-standalone.jar] at fitnesse.slim.SlimServer.serve(SlimServer.java:40)[fitnesse-standalone.jar] at fitnesse.slim.SlimService.handle(SlimService.java:164)[fitnesse-standalone.jar] at fitnesse.slim.SlimService.acceptOne(SlimService.java:172)[fitnesse-standalone.jar] at fitnesse.slim.SlimService.accept(SlimService.java:134)[fitnesse-standalone.jar] at fitnesse.slim.SlimService.startWithFactory(SlimService.java:65)[fitnesse-standalone.jar] at fitnesse.slim.SlimService.main(SlimService.java:51)[fitnesse-standalone.jar]
这是我的健康内容
!contents -R2 -g -p -f -h
!定义TEST_SYSTEM {slim}!path d:\ FitnesseTests \ IntegrationTestsMobileAdmin \ COM-Playtech的-的OpenAPI-前端服务\ com.playtech.openapi.core.fitnesse.tests \目标\类
!pomFile d:\ FitnesseTests \ IntegrationTestsMobileAdmin \ COM-Playtech的-的OpenAPI-前端服务\ com.playtech.openapi.core.fitnesse.tests \ pom.xml@compile
|进口| | com.playtech.openapi.core.fitnesse.tests |
!定义COLLAPSE_SETUP {true}
!定义COLLAPSE_TEARDOWN {true}
!|脚本| com.playtech.openapi.core.fitnesse.tests.Fixtures | | $ CONTEXT = |的createContext |
这是我的Java代码
public class Tests extends AbstractClientIT {
public String createContext(){
return "1234567";
}
}
public class Fixtures {
private Tests service2;
public String createContext () throws RemoteException {
return service2.createContext();
}
}
答案 0 :(得分:0)
public String createContext () throws RemoteException {
return service2.createContext();
}
service2尚未初始化,因此这是您的NPE
答案 1 :(得分:0)
我是FitNesse的新手,但今天我刚刚在FitNesse""测试驱动的.NET开发中找到了这个段落。第24页的书:
如果您创建了一个页面(或尝试创建一个页面)并且出现NullPointerException错误,或者该页面没有出现,则您选择了错误的名称。 FitNesse仅将CamelCase单词视为有效的页面名称,并对此严格。页面名称必须以大写字母开头,并且至少包含一个大写字母。还有一个值得注意的问题:连续大写字母。 FitNesse不喜欢他们。因此页面名称中的大写字母必须至少用一个小写字母分隔。这个惯例给FitNesse新手带来了很多麻烦,但过了一段时间你就会习惯它。