ECLIPSE+TESTNG+ANT+SELENIUM++JENKINS+SVN Automatic test framework

Source: Internet
Author: User
Tags svn xslt xslt processor testng

1. Start by writing code, install Eclipse, website download software, https://www.eclipse.org/downloads/, remember first install Java, the proposal installs JDK1.7 above.

2. The next need to write selenium's code,testng code, from selenium, Selenium-server-standalone-2.41.0.jar,testng,testng-6.8.jar website Download the corresponding jar file, put into Eclipse's directory.

4. Next you can write selenium code, write good code, the use of testng framework, testng How to use, not in detail here, refer to TestNG's official website, add testng comments in the code.

The 5.testNG XML file follows, this time executes the XML file to execute the selenium test, the final result will show how many execution success case, failure how many case.

<suite name= "Suite1" parallel= "Tests" thread-count= "5" >
  <test name= "test1" >
  <parameter name= "Myage" value= "/> <parameter name=" myname "value="
  Abel, "/>
  <groups>
     <define name= "Allfunctest" >
        <include name= "windows.*"/> <include name=
        "linux.*"/>
     </define>
     <define name= "All" >
        <include name= "allfunctest"/> <include name=
        "Functest"/>
        <exlcude name= "checkintest"/>
     </define>
     <run>
        <include name= "All"/>
        <include name= "AA"/>
        <include name= "BB"/> <include name=
        "cc"
     /> </run >
     <dependencies>
        <group name= "AA" depends-on= "BB cc"/>
     </dependencies>
  </groups>
    <classes>
       <class name= "test. TestNG "/>
    </classes>
  </test>
</suite>

6, then use Ant to invoke the testng XML file, because the last execution is executed on the Jenkins machine, so you need ant to compile, attach ant Build.xml file.

On the machine upload the Ant,eclipse testng plug-in, Ant Plug-in, I installed.

<project name= "testngtest" default= "Test" basedir=. " > <!--Define <testng> task--> <taskdef name= "testng" classname= "Org.testng.TestNGAntTask" > &L t;classpath> <pathelement location= "Lib/testng-6.8.jar"/> </classpath> </taskdef> < Property name= ' TestDir ' location= ' Build '/> <property name= ' srcdir ' location= ' src '/> <property ' name= ' li
   Bdir "location=" lib/> <property name= "Full-compile" value= "true"/> <path "id=" classpath.base
      <path id= "Classpath.test" > <fileset dir= "${libdir}" > <include name= "**/testng*.jar"/>
      </fileset> <pathelement location= "${testdir}"/> <pathelement location= "${srcdir}"/> <path refid= "Classpath.base"/> </path> <target name= "clean" > <delete verbose= "${fu" Ll-compile} "> <fileset dir=" ${testdir} "includes=" **/*.class "/>" </delete> </target> <target name= "compile" depends= "clean" > <javac srcdir= "${srcdir}" dest Dir= "${testdir}" verbose= "${full-compile}" > <classpath refid= "classpath.test"/> ac> </target> <target name= "test" depends= "compile" > <testng outputdir= "${testdir}" Classpa thref= "Classpath.test" > <xmlfileset dir= "${srcdir}" includes= "Testng_study.xml"/> </testng&
   Gt </target> </project>

7, if the above are OK, then need to submit the code to the SVN,SVN server building will not say, Linux since the belt, only need to change things on the line. There may be problems with no permissions, Authz file plus this

[/]
Username=rw

8. The success of the code submission, regarding the Eclipse code submission problem, please refer to my previous blog. Lib's jar files, code, and testng and ant XML files all need to be submitted to SVN.

6. Some are ready, then need Jenkins to call.

7.jenkins Call:

Prerequisite: Install ant on the Jenkins machine and modify the ant environment variable. The JDK is a necessity, not to say much.

Jenkins steps:

A. Check out the code through SVN

B. Invoke ant through the Jenkins Ant Plug-in, and an Oracle account number (free) is required if the Java_home error occurs and you need to install the JDK in Jenkins's system manger.

C.invoke ant before, Jenkins System management to configure the Ant plug-in, invoke time to specify the location of the Build.xml file, otherwise cannot be found, because Build.xml is not in the default workspace directory.

D. No accident, this time should be able to carry out. But how do you see the results? Install Jenkins TestNG plug-in, execute testng-results.xml file location, you can see TestNG's

E. Personal feeling testng or not beautiful, online look at the data to see TESTNGXSLT use, but I have studied, I this how can not run up, is not less this is less that ... Follow up with time to do it again.

8. To this end, the entire framework is completed, all software in the corresponding official website can be downloaded and use instructions.





Follow-up, Testngxslt resolved, will saxon-8.7.jar,saxonliaison.jar two files to the Lib folder, remember to verify that the file is wrong, double-click the file, if there is an error, the file is wrong, I just because the file has problems, so dead and right, the whole impassability, Then double-click and find the problem. Ant's Build.xml file can be added with the following content:

<path id= "Test.classpath" >
<fileset dir= "${libdir}" includes= "*.jar"/>
</path>

	< Target Name= "TestCase" >

	<property name= "dir" value= ""/> <mkdir dir=

	"${testdir}/output"/>

		
	<xslt processor= "Saxonliaison" classpathref= "Test.classpath" out= "${testdir}/output/index.html" src /testng-results.xsl "in=" ${testdir}/testng-results.xml "> <param name=" testngxslt.outputdir "expression="

	"${testdir}/output/"/>

	<param name= "Testngxslt.sorttestcaselinks" expression= "true"/>

	<param Name= "Testngxslt.testdetailsfilter" expression= "Fail,skip,pass"/>

	</xslt>

	</target>
	


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.