为了能使RestFixture-3.1在Fitnesse-20140630中正确打印测试结果,准备修改RestFixture。
以下步骤以在64位Windows7电脑上编译为例,其他平台如Linux的编译步骤大同小异。
到 https://github.com/unclebob/fitnesse 下载Fitnesse源代码zip包:
解压fitnesse-master.zip:
安装JDK网上有很多教程,以下简略介绍。
http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
jdk-7u65-windows-x64.exe
安装,并设置环境变量:
1
2
|
JAVA_HOME=C:\Program Files\Java\jdk1.
7
.0_65
Path添加内容:
";%JAVA_HOME%\bin;%JAVA_HOME%\..\jre\bin"
|
启动命令行工具cmd.exe,输入:
1
2
|
C:\Users\asus>javac -version
javac
1.7
.0_65
|
看到上述结果,说明jdk已正确安装。
网址:http://ant.apache.org/bindownload.cgi
下载 apache-ant-1.9.4-bin.zip
设置环境变量:
ANT_HOME=D:\fitnesse\apache-ant-1.9.4
Path添加内容: “;%ANT_HOME%\bin”
启动命令行工具cmd.exe,输入:
1
2
3
|
C:\Users\asus>ant
Buildfile: build.xml does not exist!
Build failed
|
看到上述结果,说明ant已正确安装。
确保编译Fitneese的电脑在联网状态,因为编译时Ant会自动下载需要的各种jar包。
命令行下进入fitnesss源代码目录,并运行ant:
1
2
3
4
5
6
7
|
D:\fitnesse\fitnesse-master>ant
...很多行打印
...几分钟后
BUILD SUCCESSFUL
Total time:
3
minutes
9
seconds
D:\fitnesse\fitnesse-master>
|
命令行下进入fitnesss源代码目录,并运行ant run:
1
2
3
|
D:\fitnesse\fitnesse-master>ant run
...很多行打印
...
1
分钟后
|
命令行下进入fitnesss源代码目录,并运行ant:
1
2
3
4
5
6
7
8
9
10
11
12
13
|
D:\fitnesse\fitnesse-master>ant
...很多行打印
...几分钟后
run:
[java] Configured verbose logging
[java] Loaded custom comparator glob: fitnesse.testsystems.slim.GlobComparator
[java] root page: fitnesse.wiki.fs.FileSystemPage at .\FitNesseRoot
[java] logger: none
[java] authenticator: fitnesse.authentication.PromiscuousAuthenticator
[java] page factory: fitnesse.html.template.PageFactory
[java] page theme: bootstrap
[java] Starting FitNesse on port:
8001
[java] Bootstrapping FitNesse, the fully integrated standalone wiki and acceptance testing framework.
|
上面运行打印的关键内容:
Starting FitNesse on port: 8001 表示在端口8001启动,所以在浏览器url栏中输入 http://localhost:8001
上面的ant run是在编译环境下启动Fitneese
编译Fitneese后生成的安装包在这里:
启动Fitneese参见这里:
Eclipse是Java开发的IDE环境,我在后面修改java代码和查找函数定义时需要用到。
http://www.eclipse.org/downloads/
因为JDK是64位的,所以必须下载64位Eclipse.
解压到D:\fitnesse :
https://github.com/smartrics/RestFixture 下载RestFixture-master.zip
并解压到D:\fitnesse
http://maven.apache.org/download.cgi 下载 apache-maven-3.2.2-bin.zip
并解压到D:\fitnesse:
设置环境变量:
M2_HOME=D:\fitnesse\apache-maven-3.2.2
Path添加内容: “;%M2_HOME%\bin”
启动命令行工具cmd.exe,输入:
1
2
3
4
5
6
7
8
|
C:\Users\asus>mvn --version
Apache Maven
3.2
.
2
(45f7c06d68e745d05611f7fd14efb6594181933e;
2014
-
06
-17T21:
51
:
4
2
+
08
:
00
)
Maven home: D:\fitnesse\apache-maven-
3.2
.
2
Java version:
1.7
.0_65, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.
7
.0_65\jre
Default locale: zh_CN, platform encoding: GBK
OS name:
"windows 7"
, version:
"6.1"
, arch:
"amd64"
, family:
"windows"
|
看到上述结果,说明maven已正确安装。
命令行下进入RestFixture源代码目录,并输入命令 mvn clean package
1
2
3
4
5
6
7
8
9
10
11
|
D:\fitnesse\RestFixture-master>mvn clean
package
...很多行
[INFO] Building zip: D:\fitnesse\RestFixture-master\target\smartrics-RestFixture-
3.1
-SNAPSHOT-bin.zip
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:
34.981
s
[INFO] Finished at:
2014
-
08
-01T06:
24
:
33
+
08
:
00
[INFO] Final Memory: 24M/123M
[INFO] ------------------------------------------------------------------------
D:\fitnesse\RestFixture-master>
|
编译后产生一个安装包:smartrics-RestFixture-3.1-SNAPSHOT-bin.zip
需要额外下载slf4j-simple-1.6.6.jar到D:\fitnesse\RestFixture-master目录下:
在Fitnesse下输入以下测试用例:
1
2
3
4
5
6
7
8
|
!define TEST_SYSTEM {slim}
!path D:/fitnesse/RestFixture-master/target/dependencies/*
!path D:/fitnesse/RestFixture-master/target/smartrics-RestFixture-
3.1
-SNAPSHOT.jar
!path D:/fitnesse/RestFixture-master/slf4j-simple-
1.6
.
6
.jar
| Table:smartrics.rest.fitnesse.fixture.RestFixture | http:
//www.w3school.com.cn |
| GET | /example/xmle/note.xml |
200
| Content-Type: text/xml |
//body[text()="Don't forget the meeting!"]|
|
点击Test运行测试:
出现打印结果直接输出html文本的问题。
我希望测试结果是这样的:
请关注后续博客,我将讲解怎样修改RestFixture源代码,并调整junit测试代码:
为Fitnesse-20140630定制RestFixture代码