zoukankan      html  css  js  c++  java
  • selenium+java+testng+ant环境搭建

    注:selenium与testng的安装及使用网上很多例子,这里主要是记录一下本人在搭建ant环境中的一些例子

    一。安装

    1、 到 http://ant.apache.org/bindownload.cgi 下载 ant发布版本

    2、 将下载后的 zip 文件解压缩到任意目录,比如 D:\ant

    3、 在环境变量中增加 ANT_HOME=D:\ant( 替换成你解压缩的目录 )

    4、 在环境变量 path 中增加 ;D:\ant\bin;

    5、 打开 cmd ,输入 ant ,如果提示一下信息证明成功了

    Buildfile: build.xml does not exist!

    Build failed

     或者

    安装ant

    将你下载的压缩包解压,然后放在你喜欢的任何位置,如:c:/ant/,然后在“我的电脑->属性->高级->环境变量 ->新建”指定:ANT_HOME,值为:c:/ant,并在classpath中添加:%ANT_HOME%\bin;

    二。说明

    1、安装完成后,

    打开 cmd ,输入 ant ,如果提示一下信息证明成功了

    Buildfile: build.xml does not exist!

    Build failed

    这里的failed并不是指你的Ant安装失败了,而是因为你只输入ant命令后,会在你当前目录下去寻找一个叫build.xml的文件,如果你当前目录下没有这个build.xml的文件,则会报build.xml does not exist!,而build.xml里存放的是你需要去干的一些事情,比如构建,执行,等

    2、我在工程下面,即bin与src的同目录下建了一个lib的文件夹,把所有需要用到的jar包全放到里面,然后在build.xml里面去引用,

    具体的build.xml文件:

    <?xml version="1.0" encoding="UTF-8" ?>
    <project name="selenium" default="start_server_and_run_tests" basedir=".">
    <property name="src" value="src"/>
    <property name="dest" value="classes"/>
    <!--<property name="lib.dir" value="lib" />-->
    <property name="lib.dir" value="${basedir}/lib"/>
    <property name="suite.dir" value="${basedir}/test-output/suite"/>
    <property name="selenium_jar" value="selenium.jar"/>
    <path id="compile.path">
    <fileset dir="${lib.dir}/">
    <include name="*.jar"/>
    </fileset>
    <pathelement location="${src}"/>
    <pathelement location="${dest}"/>
    </path>
    <target name="init">
    <mkdir dir="${dest}"/>
    </target>
    <target name="compile" depends="init">
    <javac srcdir="${src}" destdir="${dest}" classpathref="compile.path"/>
    </target>
    <!--run testng ant task-->
    <taskdef resource="testngtasks" classpath="${lib.dir}/testng.jar"/>

    <target name="start_server_and_run_tests" depends="compile" description="start selenium server and run tests">
    <parallel>
    <antcall target="run_tests">
    </antcall>
    </parallel>
    </target>

    <target name="run_tests" depends="compile">
    <testng classpathref="compile.path" failureproperty="test.failed">
    <!--xml test suite file -->
    <xmlfileset dir="${suite.dir}">
    <include name="test.xml"/>
    </xmlfileset>
    </testng>
    <antcall target="sendReport"/>
    <fail message="ERROR: test failed!!!!!" if="test.failed"/>
    </target>
    <target name="sendReport">
    <delete dir="${dest}"/>
    <antcall target="transform"/>
    </target>
    <target name="transform">
    <xslt in="${basedir}/test-output/testng-results.xml" style="${basedir}/test-output/testng-results.xsl" out="${basedir}/test-output/index1.html" classpathref="compile.path" processor="SaxonLiaison">
    <!-- you need to specify the directory here again -->
    <param name="testNgXslt.outputDir" expression="${basedir}/test-output/"/>
    <param name="testNgXslt.showRuntimeTotals" expression="true"/>
    <!--<classpath refid="compile.path" />-->
    </xslt>
    </target>
    </project>
  • 相关阅读:
    在浏览器中输入URL并回车后都发生了什么?
    HashMap数据结构
    记录一次mysql死锁
    常见排序(归并排序)
    记录一次redis事故
    jsp与javaBean
    org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.zhuoshi.entity.Dep#1]
    Oracle创建表空间报错:O/S-Error: (OS 3) 系统找不到指定的路径
    在myeclipse中maven项目关于ssh整合时通过pom.xml导入依赖是pom.xml头部会报错
    2018idea如何布置tomcat修改URL后连接不到
  • 原文地址:https://www.cnblogs.com/zhangfei/p/2007579.html
Copyright © 2011-2022 走看看