1

I cannot run even the most basic example in FitNesse.

Either I get this error

__EXCEPTION__:java.lang.NoClassDefFoundError: MyTestFixture (wrong name: my/package/MyTestFixture)

or I get this error

Could not invoke constructor for my.package.MyTestFixture,

depending on whether I add the full package name to the header of my test table or not (see example below).

My FitNesse code looks like this:

!define TEST_SYSTEM {slim}

!path   D:\tools\FitNesse\
!path   D:\Users\myName\workspace\myProject\target\

!|import|
|my.package|

!|my.package.MyTestFixture|
|TestInt1            |test int 2            |product?            |
|5                   |2                     |10                  |
|10                  |5                     |50                  |
|25                  |0                     |0                   |
|2                   |-2                    |-4                  |
|5                   |0.1                   |1                   |

!define COLLAPSE_SETUP {true}
!define COLLAPSE_TEARDOWN {true}

The first !path points to the directory containing fitnesse-20140418.jar, the second path points to MyTestFixture.class.

Here the java code of MyTestFixture:

package my.package;

public class MyTestFixture {
    private int testInt1;
    private int testInt2;

    public void setTestInt1(int number) {
        this.testInt1 = number;
    }

    public void setTestInt2(int number) {
        this.testInt2 = number;
    }

    public int getProduct() {
        return testInt1 * testInt2;
    }
}

I'm using JDK 1.6 and Eclipse + Maven. FitNesse runs on a local service (via fitness-standalone.jar). fitnesse-20140418.jar is a dependency in Maven's pom.xml and is also located at D:\tools\FitNesse. I basically read everything Google spit out on these errors, including Stack Overflow.

What can I do to make this example run?

Mike Stockdale
  • 5,256
  • 3
  • 29
  • 33
Roland
  • 21
  • 1
  • 4

1 Answers1

1

I managed to solve it.

This website helped me find the correct solution: http://www.erikojebo.se/Code/Details/247

Instead of !path D:\Users\myName\workspace\myProject\target I had to point to D:\Users\myName\workspace\myProject\target\classes (or simply 'bin' if you don't use Maven). It will then resolve to the correct class sub-folder via given import statement.

Roland
  • 21
  • 1
  • 4