博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
selenium+testNG+Ant
阅读量:6274 次
发布时间:2019-06-22

本文共 3528 字,大约阅读时间需要 11 分钟。

好几天没写了,抽时间写下,也好有个总结:

1.selenium+testNG+Ant

  (1)ant 是构建工具 他的作用就是运行你配置好的东西 而tentng.xml你可以认为他是管理test的一个配置。在ant中配置运行testng 启动testng的时候 就会运行testng里面配置好的东西。

  (2)eclipse 中给项目自动创建ant的build.xml文件

     Eclipse 自动生成 Ant的Build.xml 配置文件,生成的方法很隐蔽 选择你要生成Build.xml文件的项目,右键. Export-> General -> Ant Buildfiles .点Next,再点Finish.生成完毕.

  (3)

1 Buildfile: D:\myFile\file\eclispe.work\aista\build.xml 2 build-subprojects: 3 init: 4 build-project: 5 [echo] aista: D:\myFile\file\eclispe.work\aista\build.xml 6 [javac] D:\myFile\file\eclispe.work\aista\build.xml:123: warning: 'includeantruntime' was not set, defaulting to 7 8 build.sysclasspath=last; set to false for repeatable builds 9 [javac] D:\myFile\file\eclispe.work\aista\build.xml:127: warning: 'includeantruntime' was not set, defaulting to 10 11 build.sysclasspath=last; set to false for repeatable builds 12 [javac] D:\myFile\file\eclispe.work\aista\build.xml:132: warning: 'includeantruntime' was not set, defaulting to 13 14 build.sysclasspath=last; set to false for repeatable builds 15 [javac] D:\myFile\file\eclispe.work\aista\build.xml:136: warning: 'includeantruntime' was not set, defaulting to 16 17 build.sysclasspath=last; set to false for repeatable builds 18 build: 19 BUILD SUCCESSFUL 20 Total time: 575 milliseconds
View Code

    解决:<javac srcdir="${build.src}" destdir="${build.dest}">

    改为<javac srcdir="${build.src}" destdir="${build.dest}" includeantruntime="on"/>

  (4)配置Ant的build.xml文件:eclipse Target "build" does not exist in the project 

     <project name="AntExample" default="secondTarget" basedir=".">

     这个里面的default设定了默认执行的目标,也就是dos下执行ant命令不加参数时,会默认执行default中设定的目标
     你的default是secondTarget但是这里:
        <targle name="secondTargle">
               <echo>${secondText}</echo>
        </targle>
     name是secondTargle和上面default中设置的不一样,只要设为一样就行了
   (5)

Buildfile: D:\myFile\file\eclispe.work\sysframe-normal-test\build.xmlinit:compile:     [echo] compile testsrun_tests:     [echo] running tests     [echo] D:\myFile\file\eclispe.work\sysframe-normal-test\classes   [testng] java.lang.NoClassDefFoundError: com/beust/jcommander/ParameterException   [testng]     at java.lang.Class.getDeclaredMethods0(Native Method)   [testng]     at java.lang.Class.privateGetDeclaredMethods(Class.java:2451)   [testng]     at java.lang.Class.getMethod0(Class.java:2694)   [testng]     at java.lang.Class.getMethod(Class.java:1622) [testng] at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494) [testng] at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486) [testng] Caused by: java.lang.ClassNotFoundException: com.beust.jcommander.ParameterException [testng] at java.net.URLClassLoader$1.run(URLClassLoader.java:366) [testng] at java.net.URLClassLoader$1.run(URLClassLoader.java:355) [testng] at java.security.AccessController.doPrivileged(Native Method) [testng] at java.net.URLClassLoader.findClass(URLClassLoader.java:354) [testng] at java.lang.ClassLoader.loadClass(ClassLoader.java:423) [testng] at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) [testng] at java.lang.ClassLoader.loadClass(ClassLoader.java:356) [testng] ... 6 more [testng] Exception in thread "main" [testng] The tests failed. transform: [xslt] Processing D:\myFile\file\eclispe.work\sysframe-normal-test\lib\testng-results.xml to D:\myFile\file \eclispe.work\sysframe-normal-test\test-output\Report.html [xslt] Loading stylesheet D:\myFile\file\eclispe.work\sysframe-normal-test\lib\testng-results.xsl BUILD SUCCESSFUL Total time: 2 seconds
View Code

     发现testNG.jar的版本不对

转载于:https://www.cnblogs.com/loveok-56/p/4438349.html

你可能感兴趣的文章
iptables实现网络防火墙(一)
查看>>
SAVE
查看>>
MFC 导入EXCEL到数据库
查看>>
【ASP.NET 类库】当你懒得用 Json+Ajax 时,可以试试 AjaxPro
查看>>
使用深度学习检测DGA(域名生成算法)——LSTM的输入数据本质上还是词袋模型...
查看>>
【转】利用mybatis-generator自动生成代码
查看>>
架构师应该了解的知识1
查看>>
在Flex (Flash)中嵌入HTML 代码或页面—Flex IFrame
查看>>
防止Direct Input获取多次输入
查看>>
Interspeech 2017 | Self-adaptive Speech Recognition Technology
查看>>
Linux中MySQL数据库max_allowed_packet的调整
查看>>
MySQL 学习笔记 二
查看>>
Host prepare for your automation work
查看>>
Thinkphp中field和getField
查看>>
AngularJS之初级Route【一】(六)
查看>>
QTP的那些事--采用DOM,描述性编程获取指定的对象
查看>>
linux异步通信之epoll【转】
查看>>
前端自学路线之js篇
查看>>
C++:运算符重载函数之友元运算符重载
查看>>
ANT task之Junit、JunitReport
查看>>