Java+TestNG+Maven+Excel+IDEA接口自动化入门(一)环境配置

  • 前置:

1.本机环境安装了maven并配置环境变量

2.本机环境安装了IDEA软件

3.本机环境安装了Java jdk 8版本

4.有一定java和maven基础

因为以上网上例子很多,就不再重复赘述了

 

一、新建maven项目,在生成的pom.xml中配置所需jar包

Java+TestNG+Maven+Excel+IDEA接口自动化入门(一)环境配置_第1张图片

 

 

xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0modelVersion>
    <properties>
        <project.build.sourceEncoding>UTF-8project.build.sourceEncoding>
    properties>
    <groupId>org.examplegroupId>
    <artifactId>TestartifactId>
    <version>1.0-SNAPSHOTversion>

    <dependencies>
        <dependency>
            <groupId>org.testnggroupId>
            <artifactId>testngartifactId>
            <version>6.8.21version>
        dependency>
        <dependency>
            <groupId>org.apache.httpcomponentsgroupId>
            <artifactId>httpclientartifactId>
            <version>4.3.5version>
        dependency>
        <dependency>
            <groupId>com.alibabagroupId>
            <artifactId>dubbo-serialization-fastjsonartifactId>
            <version>2.6.7version>
        dependency>
        <dependency>
            <groupId>mysqlgroupId>
            <artifactId>mysql-connector-javaartifactId>
            <version>5.1.24version>
        dependency>
        <dependency>
            <groupId>org.uncommonsgroupId>
            <artifactId>reportngartifactId>
            <version>1.1.4version>
            <scope>testscope>
            <exclusions>
                <exclusion>
                    <groupId>org.testnggroupId>
                    <artifactId>testngartifactId>
                exclusion>
            exclusions>
        dependency>
        <dependency>
            <groupId>com.google.injectgroupId>
            <artifactId>guiceartifactId>
            <version>3.0version>
            <scope>testscope>
        dependency>
        <dependency>
            <groupId>com.hynnetgroupId>
            <artifactId>jxlartifactId>
            <version>2.6.12.1version>
        dependency>
        <dependency>
            <groupId>org.apache.poigroupId>
            <artifactId>poiartifactId>
            <version>3.17version>
        dependency>
    dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-compiler-pluginartifactId>
                <version>3.1version>
                <configuration>
                    <source>1.8source>
                    <target>1.8target>
                    <encoding>UTF-8encoding>
                configuration>
            plugin>
            <plugin>
                <groupId>org.apache.maven.pluginsgroupId>
                <artifactId>maven-surefire-pluginartifactId>
                <version>2.5version>
                <configuration>
                    <testFailureIgnore>truetestFailureIgnore>
                    
                    <suiteXmlFiles>
                        <file>testNG.xmlfile>
                    suiteXmlFiles>
                    <properties>
                        <property>
                            <name>usedefaultlistenersname>
                            <value>falsevalue>
                        property>
                        <property>
                            <name>listenername>
                            <value>org.uncommons.reportng.HTMLReportervalue>
                        property>
                    properties>
                configuration>
            plugin>
        plugins>
    build>
project>

此时右下角会弹出提示,选择“Import Changes”,会自动下载依赖

 

 

接下来要做的就是等它下载完成。

 

二、生成testng.xml

File->Settings-Plugins  下载Create TestNG XML 插件,重启IDEA即可。

Java+TestNG+Maven+Excel+IDEA接口自动化入门(一)环境配置_第2张图片

 

 

打开testNG.xml

xml version="1.0" encoding="UTF-8"?>DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Suite1">
            
    <test name="Get方法测试" verbose="2"> 
        <classes>
            
            <class name="GetDemo" />
        classes>
    test>
    <test name="Post方法测试" verbose="2">
        <classes>
            <class name="PostDemo"/>
        classes>
    test>
suite>

至此所有配置完成

你可能感兴趣的:(Java+TestNG+Maven+Excel+IDEA接口自动化入门(一)环境配置)