javafitnesseselenium-fitnesse-bridge

How to test or call a java method using fitnesse?


My requirement is to test or call a java method directly through fitnesse tool. I have used this tool for REST testing, but never for calling java methods directly. Also googled , but no solution. Any help would be appreciated.

Thanks


Solution

  • I found the answer finally :

    To call any method of any Java class, just use Generic Fixture Eg.

    Java class :

    package com.fitnesse.fixtures;
    
    
    public class HelloWorld {
    
        public long getValue()
        {
            return 10;
        }
    
    }
    

    Fitnesse script to call the fore-mentioned java class :

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

    So first line calls the default constructor of the Java class, and
    second line calls the method getValue and saves it in myvar and also validates it with 10.