HelloWood

使用Gradle编译执行Gague项目

2018-01-01

使用Gradle编译运行Gauge项目可以很大程度解决依赖的问题,并且可以根据需要创建多个不同的Task来在不同的环境运行或执行不同的操作


创建Gauge项目

  • 首先在IDEA中创建一个Gauge项目
    这里写图片描述
  • 打开命令行,执行gradle init 初始化Gradle项目
    这里写图片描述
  • 修改build.gradle文件,添加Gauge的依赖
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'gauge'

group = "Gradle-Gauge"
version = "1.0.0"


sourceCompatibility = 1.7
targetCompatibility = 1.7

buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.thoughtworks.gauge.gradle:gauge-gradle-plugin:+'
}
}

repositories {
mavenCentral()
}

dependencies {
//添加selenium是为了执行网页测试
compile(
'com.thoughtworks.gauge:gauge-java:0.5.1',
'junit:junit:4.12',
'org.seleniumhq.selenium:selenium-chrome-driver:3.0.1',
'org.seleniumhq.selenium:selenium-support:3.0.1'
)
}

//执行`gradle gague`时是在执行该Task
gauge {
specsDir = 'specs'
}
  • 执行gradle build来编译项目,并下载依赖
  • 执行gradle gauge来运行Gauge项目,执行测试