从零开始自动化测试框架设计:自动化测试环境搭建一:eclipse+svn+selenium+Junit+maven

本机环境:window7 旗舰版 Service Pack 1 64位操作系统

一、安装JDK:官网下载jdk1.6.0_17或以上版本,本人用的是jdk1.6.0_17.下载完后安装在C盘根目录C:\jdk1.6.0_17,配置系统环境变量:PATH: C:\jdk1.6.0_17\bin; CLASSPATH: .;C:\jdk1.6.0_17\lib\dt.jar;C:\jdk1.6.0_17\lib\tools.jar; cmd中运行java -version;javac 出现相关信息成功。

二、安装eclipse,下载Eclipse Kepler (4.3.1),安装

三、eclipse中安装svn和maven插件:

1.DownloadMaven

http://maven.apache.org/download.html

apache-maven-3.1.1-bin.tar.gz

http://www.apache.org/dyn/closer.cgi/maven/binaries/apache-maven-3.1.1-bin.tar.gz

2.InstallMaven

(1) Unzip apache-maven-3.1.1-bin.tar.gz to E:\apache-maven-3.1.1

(2) My Computer --> Property --> EnvironmentVariant–> System Variant–>

Add–>choosePath–>edit–>add the last: ;E:\apache-maven-3.1.1\bin–>OK–>OK–>OK

(3) cmd–> mvn -v

Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 23:22:2
2+0800)
Maven home: E:\apache-maven-3.1.1
Java version: 1.6.0_17, vendor: Sun Microsystems Inc.
Java home: C:\jdk1.6.0_17\jre
Default locale: zh_CN, platform encoding: GBK
OS name: “windows 7”, version: “6.1”, arch: “x86”, family: “windows”

3.Use Maven in Eclipse

(1) cmd–>mvn help:system (This willdownload many files to .m2 folder)

(2) copy M3_HOME\conf\settings.xml to .m2/settings.xml

(3) Start Eclipse–>Help–>Install NewSoftware…–>Add…–>

Name: m2e

Location: http://download.eclipse.org/technology/m2e/releases

–>OK–>Choose m2e- Maven Integration for Eclipse—>Next–>Next–>I accept the terms ofthe license agreement–>Finish–>Restart Now

(4) Start Eclipse–>Help–>Install NewSoftware…–>Add…–>

Name: subclipse

Location: http://subclipse.tigris.org/update_1.8.x

–>ChooseSubclipse,SVNKit all–>Next–>Next–>I accept the terms of the licenseagreement–>Finish–>OK–>Restart Now

(5) StartEclipse–>File–>New–>Other…–>Maven–>Maven Project–>Ifyou see Maven Project ,it is said that Maven is installed perfectly.

(6) Use Maven outside of Eclipse,Windows --> Preferences–> Maven–>Installations–> Add…–> Next–> E:\apache-maven-3.1.1–>OK–>OK

  1. First Maven Project : hello-world-m2e (EclipseIDE)(Create a new Maven project)

(1) Start Eclipse–>File–>Other…–>Maven–>MavenProject–>Cancel Use default Workspace location–>Location:…\workspace–>Next–>Next–>

org.apache.maven.archetypes: maven-archetype-quickstart–>

Next–>

Group Id:com.lijiming

Artifact Id:test

Version: 0.0.1-SNAPSHOT

Package:com.lijiming.test

–>Finish–>

(2) Run maven(mvn clean install)–>point pom.xml–>Run As–>Maven install–>

(3) We want to run mvn clean test -->point pom.xml–>Run As–>Run Configurations–>MavenBuild–>New–>

Name: test

Base directory:${workspace_loc:/test}

Goals: clean test

–>JRE–>InstalledJREs…–>Add…–>StandardVM–>Next–>Directory…–>C:\jdk1.6.0_17–>Finish–>

choose jdk1.6.0_17–>ok–>AlternateJRE: jdk1.6.0_31–>Apply–>Run

POM.xml文件内容:

<?xml version="1.0" encoding="UTF-8"?>


4.0.0
com.lijiming
test
1.0


org.seleniumhq.selenium
selenium-java
2.37.0


junit
junit
4.11

com.opera operadriver com.opera operadriver 1.5 org.seleniumhq.selenium selenium-remote-driver org.apache.maven.plugins maven-surefire-plugin 2.16 **/*AppTest.java **/SampleTest.java org.apache.maven.plugins maven-compiler-plugin 3.1 1.6 1.6 utf8 org.apache.maven.plugins maven-site-plugin 3.3 zh_CN utf-8 org.apache.maven.plugins maven-surefire-report-plugin 2.16 true



作者:马克社区何老师