如何在Graphwalker项目中使用在YED中制作的图形?

时间:2018-08-23 12:03:44

标签: java selenium model-based-testing graphwalker

对于使我的代码使用graphwalker进行基于模型的测试遍历图形的方式,我感到非常困惑。

我已使用yEd构造了一个图形(e2e.graphml),并将该文件复制到了Eclipse中的项目中。我还用每个边缘和顶点的方法创建了一个接口。接下来,我为我的接口创建了一个实现类,其中提供了很少的功能,这些功能在遍历该边或顶点时需要执行。接下来,我执行了如下功能测试:

@Test()
public void runFunctionalTest() throws IOException {
    Context context = new MyClass();
    TestBuilder builder = new TestBuilder().setContext(context);
    builder.setModel(MODEL_PATH);
    context.setPathGenerator(new RandomPath(newReachedVertex("v_Success")));
    builder.setStart("v_Start");
    builder.execute();
}

在这里,MODEL_PATH是我用来提供yEd文件位置或路径的变量。 每当我运行此测试时,都不会遍历任何边或顶点,并且错误日志如下:

java.lang.NullPointerException
at org.graphwalker.core.condition.ReachedStopConditionBase.validate(ReachedStopConditionBase.java:52)
at org.graphwalker.core.condition.ReachedStopConditionBase.setContext(ReachedStopConditionBase.java:48)
at org.graphwalker.core.generator.PathGeneratorBase.setContext(PathGeneratorBase.java:49)
at org.graphwalker.core.machine.ExecutionContext.setPathGenerator(ExecutionContext.java:179)
at gw.MyClass.runFunctionalTest(MyClass.java:277)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
at org.testng.TestRunner.privateRun(TestRunner.java:767)
at org.testng.TestRunner.run(TestRunner.java:617)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:348)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:343)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:305)
at org.testng.SuiteRunner.run(SuiteRunner.java:254)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
at org.testng.TestNG.run(TestNG.java:1057)
at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

在生成路径时给出错误。如果我执行错误的方式,请提供帮助。谢谢!

0 个答案:

没有答案