junJZ_2008 发表于 2013-2-3 10:30:12

JsUnit详解——Web服务方式(三)

上两节提到过以Web方式来运行JsUnit,不过不是很详细,这节我们专来看看Web服务方式下的JsUnit。
 
因为JsUnit里集成了Jetty,通过命令行使用Ant就可以启动JsUnit服务了,所以我们先应该配置好Ant。
 
首先下载 Ant ,登录http://ant.apache.org/即可找到下载连接。
 
下载后会得到 apache-ant-1.7.1-bin.zip 象这样的压缩包,解开即可。
 
然后设置环境变量 ANT_HOME ,我的为 E:\apache-ant-1.7.1 ,然后还要在 path 环境变量中加添 ant 命令的路径,以便在任何工作路径下都能使用 ant 命名,我的配置为 %ANT_HOME%/bin 。当然JDK可不能忘记哦,这里我就不讲了。
 
配置完成后,我们进到命令行,输入 ant ,回车,如出现以下信息说明配置成功:
E:\>ant
Buildfile: build.xml does not exist!
Build failed
E:\>
 
Ant配置好后,我们开始拉起JsUnit Web 服务,先要进到 jsunit 主目录,然后输入 ant start_server 即可,运行过程如下:
E:\>cd jsunit2.2
E:\jsunit2.2>cd jsunit
E:\jsunit2.2\jsunit>ant start_server
Buildfile: build.xml

start_server:
     2009-10-20 23:16:12 net.jsunit.AbstractJsUnitServer logStatus
     信息: Starting Standard Server with configuration:
     <configuration type="STANDARD">
        <os>x86 - Windows XP</os>
        <ipAddress>192.168.1.100</ipAddress>
        <hostname>192.168.1.100</hostname>
        <browserFileNames>
          <browserFileName id="0">C:\Program Files\Internet Explorer\iexpl
ore.exe</browserFileName>
        </browserFileNames>
        <closeBrowsersAfterTestRuns>false</closeBrowsersAfterTestRuns>
        <description />
        <logsDirectory>E:\jsunit2.2\jsunit\logs</logsDirectory>
        <port>8080</port>
        <resourceBase>E:\jsunit2.2\jsunit\.</resourceBase>
        <timeoutSeconds>60</timeoutSeconds>
        <url>file:/E:/jsunit2.2/jsunit/testRunner.html?testPage=E:/jsunit2
.2/customSuit.html</url>
     </configuration>
 
以上信息表示JsUnit服务已启动,注:以上粗体是 jsunit/build.xml 配置的,具体请参考上一节。
 
下面我们来用浏览器打开JsUnit服务的主页面,在地址栏中输入 http://localhost:8080/jsunit/ :

http://dl.iteye.com/upload/attachment/159011/57c11328-ee33-3652-904f-606c65b7fa1f.gif
上面显示了Server configuration 信息,即 build.xml 部署文件里配置的相应信息,下面来看看各项意思:
Server type:Standard  表示以标准方式启动JsUnit服务的,即我们这种方式
Browser file names:C:\Program Files\Internet Explorer\iexplore.exe  表示我们所配置浏览器运行程序所在路径
页: [1]
查看完整版本: JsUnit详解——Web服务方式(三)