无法运行规范的Fitnesse示例 - java.lang.NoClassDefFoundError

时间:2016-07-06 15:37:50

标签: fitnesse

此测试来自Fitnesse用户指南。

!path /Users/mpalanisamy/learningfitnesse/myProject/bin/myPackage
!path /Users/mpalanisamy/learningfitnesse/myProject/src/myPackage
!path /Users/mpalanisamy/Downloads/fitnesse-standalone.jar
!path /Users/mpalanisamy/Downloads/FitNesseRoot
!define TEST_SYSTEM {fit}

!|DivisionFixture|
|num|denom|quotient()|
|1|2|0.5|
|1|2|0.6|
|4|2|2.0|

系统测试和夹具代码如下 - Division.java

package myPackage;

public class Division {

    private double numerator;
    private double denominator;

    public Division(double a, double b){
        this.numerator = a;
        this.denominator = b;
    }

    public double divide(){
        return this.numerator / this.denominator;
    }
}

DivisionFixture.java

package myPackage;

import myPackage.Division;

public class DivisionFixture extends fit.ColumnFixture{
    public double num, denom;

    private Division d = new Division(num, denom);

    public double quotient(){
        return d.divide();
    }
}

/ Users / mpalanisamy / learningfitnesse / myProject / bin / myPackage - 包含我的.class文件 / Users / mpalanisamy / learningfitnesse / myProject / src / myPackage - 包含我的.java文件

当我运行此测试时,我收到以下错误 -

java.lang.NoClassDefFoundError: DivisionFixture (wrong name: myPackage/DivisionFixture)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at fit.FixtureLoader.loadFixtureClass(FixtureLoader.java:66)
    at fit.FixtureLoader.instantiateFixture(FixtureLoader.java:59)
    at fit.FixtureLoader.instantiateFirstValidFixtureClass(FixtureLoader.java:82)
    at fit.FixtureLoader.disgraceThenLoad(FixtureLoader.java:43)
    at fit.Fixture.loadFixture(Fixture.java:142)
    at fit.Fixture.getLinkedFixtureWithArgs(Fixture.java:134)
    at fit.Fixture.doTables(Fixture.java:79)
    at fit.FitServer.process(FitServer.java:81)
    at fit.FitServer.run(FitServer.java:56)
    at fit.FitServer.main(FitServer.java:41)

执行日志有这个 -

/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/bin/java -cp /Users/mpalanisamy/Downloads/fitnesse-standalone.jar:/Users/mpalanisamy/learningfitnesse/myProject/bin/myPackage:/Users/mpalanisamy/learningfitnesse/myProject/src/myPackage:/Users/mpalanisamy/Downloads/fitnesse-standalone.jar:/Users/mpalanisamy/Downloads/FitNesseRoot fit.FitServer my_mac.local 53339 3863

- 它告诉我我的课程路径是正确的,或者Fitnesse知道它。

FWIW,所有文件都具有rwxr-xr-x权限。

鉴于上述情况,为什么我会收到NoClassDefFoundError错误?

我已经浏览了StackOverflow并整合了大部分修复程序,但仍无法运行这个简单的示例。鉴于错误的性质,我认为解决方案对我来说是愚蠢的,和/或与配置有关。

我看到的截图,如果有帮助的话 - fitnesse error

1 个答案:

答案 0 :(得分:0)

问题结果是类路径,如错误所示。

我必须将类路径更改为以下内容 -

!path /Users/mpalanisamy/learningfitnesse/myProject/bin
!define TEST_SYSTEM {fit}

将测试表的第一行更改为 -

!|myPackage.DivisionFixture|