我想开始使用 Fitnesse 测试我的 Java 应用程序,但一开始我遇到了一个大问题。
我测试我非常简单的课程的健身页面是:
!contents -R2 -g -p -f -h
!define TEST_SYSTEM {slim}
!path /home/user/NetBeansProjects/dotestow/build/classes/dotestow/
!|dodawanie|
|l1|l2|add?|
|10|2|12|
|10|35|45|
|60|4|33|
我的类只是 NetBeans 创建的普通 Java 类,代码如下:
package dotestow;
public class Dotestow {
private int l1, l2;
public void setL1(int l1) {this.l1 = l1;}
public void setL2(int l2) {this.l2 = l2;}
public int add()
{
return l1+l2;
}
}
当我点击测试时,它只显示:
Exception in thread "main" java.lang.NoClassDefFoundError: fitnesse/slim/SlimService
Caused by: java.lang.ClassNotFoundException: fitnesse.slim.SlimService
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: fitnesse.slim.SlimService. Program will exit.
我究竟做错了什么??
@@编辑
当我跑
java Dotestow
在我的 /Dotestow/build/classes 目录中,我得到了输出:
Exception in thread "main" java.lang.NoClassDefFoundError: Dotestow (wrong name: dotestow/Dotestow)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:634)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: Dotestow. Program will exit.