如何使用fitnesse测试或调用java方法?

如何使用fitnesse测试或调用java方法?,java,fitnesse,selenium-fitnesse-bridge,Java,Fitnesse,Selenium Fitnesse Bridge,我的需求是通过fitnesse工具直接测试或调用java方法。我将此工具用于REST测试,但从未用于直接调用java方法。也在谷歌上搜索,但没有解决方案。 任何帮助都将不胜感激 谢谢您需要编写将FitNesse连接到Java类的“fixture”代码 您可以在此处找到详细信息: 例如,这里有一些关于一种方法的信息:我终于找到了答案: 要调用任何Java类的任何方法,只需使用泛型Fixture 例如 Java类: package com.fitnesse.fixtures; public cl

我的需求是通过fitnesse工具直接测试或调用java方法。我将此工具用于REST测试,但从未用于直接调用java方法。也在谷歌上搜索,但没有解决方案。 任何帮助都将不胜感激


谢谢

您需要编写将FitNesse连接到Java类的“fixture”代码

您可以在此处找到详细信息:


例如,这里有一些关于一种方法的信息:

我终于找到了答案:

要调用任何Java类的任何方法,只需使用泛型Fixture 例如

Java类:

package com.fitnesse.fixtures;


public class HelloWorld {

    public long getValue()
    {
        return 10;
    }

}
!| Generic Fixture | com.fitnesse.fixtures.HelloWorld|
|myvar=getValue||10|
Fitnesse脚本调用前面提到的java类:

package com.fitnesse.fixtures;


public class HelloWorld {

    public long getValue()
    {
        return 10;
    }

}
!| Generic Fixture | com.fitnesse.fixtures.HelloWorld|
|myvar=getValue||10|

因此,第一行调用Java类的默认构造函数,第二行调用方法getValue并将其保存在myvar中,还使用10对其进行验证。

使用脚本表可以执行以下操作:

对于静态方法

|script   |java.util.UUID.randomUUID|
|$uuidVar=|to string                |
|check    |to string                | $uuidVar |
|script             | MyClass       |constructor   |arguments|here|
|$classToString=    | to string     |
|check              | to string     |$classToString|
|$classReference=   | get fixture   |
|$storeMethodOutput=| my method name|
对于非静态方法

|script   |java.util.UUID.randomUUID|
|$uuidVar=|to string                |
|check    |to string                | $uuidVar |
|script             | MyClass       |constructor   |arguments|here|
|$classToString=    | to string     |
|check              | to string     |$classToString|
|$classReference=   | get fixture   |
|$storeMethodOutput=| my method name|

定义的任何$variables都可以在以后的表中引用,以满足您的任何需要。

感谢这些链接,我写了一个fixture:!定义TEST_RUNNER fitlibrary.suite.FitLibraryServer!路径C:\Fitnesse_1\Fitnesse.jar!路径C:\Fitnesse_1\fitlibrary.jar!路径C:\Fitnesse_1\com.jar|com.fitnesse.HelloWorldFixture | | show | say hi |,但当我运行它时,它显示错误:无法找到或加载主类fitbrary.suite.fitbraryserver您在页面中导入了fixture吗?