0

I am starting with Fitnesse, and try to Test the following:

!define TEST_SYSTEM {slim}

!path C:\Users\binF\java

|import|
|org.magmax|

|multiplication|
|factor|factor|multiply?|
|4|2|8|
|44|12|8|

I have the file multiplication.class in the specified path, the code:

package org.magmax;

import java.util.ArrayList;
import java.util.List;


public class multiplication {
    private ArrayList<Integer> factors = new ArrayList<Integer>();

    public void setFactor(int n) {
        factors.add(n);
    }

    public long multiply() {
        long result = 1;
        for (Integer i: factors) {
            result *= i;
        }
        return result;
    }
}

Then, I execute the Test and returns the error of the type:

Multiplication factor multiply? 4 The instance decisionTable_1.setFactor. does not exist

Can you help me? I do not know to fix this error Many thanks in advance for your comments.

Mike Stockdale
  • 5,256
  • 3
  • 29
  • 33
user123043
  • 121
  • 5
  • The standard convention for Java classes is to start their name with a capital. Does naming the class Multiplication make a difference? – Fried Hoeben Apr 07 '18 at 08:32
  • As @Fried said, the standard naming convention says to start with cappital letter, but this is not the issue here. I think you must precede the class name, including package, with exclamation mark, like: !|org.magmax.multiplication| and remove the import section above it. – VeryNiceArgumentException Apr 08 '18 at 16:30
  • Thanks friends. I have generated the class "Multiplication.class", putting "public class Multiplication " and edit the Fitnesse page adding "!|org.magmax.Multiplication| " (after remove the import section above it), but returns the error "Could not invoke constructor for Multiplication[0]" and "The instance decisionTable_1.setFactor. does not exist" – user123043 Apr 09 '18 at 06:18

1 Answers1

0

Your test script and the class are correct. It is just a typo in your !path C:\Users\binF\java. The !path should point to the folder that contains the package.

I managed to reproduce the error by misspelling the path. Below are the screenshots

enter image description here

After correcting the path, below is the successful run of the test:

enter image description here

user2347763
  • 469
  • 2
  • 10