安裝:html
* 安裝插件 Gauge--install-alljava
*在IDEA中安裝Gauge插件git
基本思想github
* Gauge
的基本思想就是經過.spec
或.md
文件,使用MarkDown
語法去規定執行的動做,而後由Java
或者其餘語言的文件去按照所寫的.spec
或者.md
文件的順序去執行Java
文件,從而達到測試的目的緩存
專業術語:app
1 Specification工具
Specification name ================== 或者: # Specification name
2.Scenario測試
Scenario name
---------------------- 或者 ##scenario name
3 Step ui
* Login into my app * Search for "gauge" * Search for "gauge-java"
4.Tagsspa
specification sp1 ========= Tags : spec,login Scenario ------------- Tags: scenario,main-page
5.cioncept
6.Parameters
check "param" exists
check <param> exists
|id|name| |--|--------| |1|tom| |2| mike|
File: * Verify email text is <file:email.txt> * Check if <file:/work/content.txt> is visible CSV: * Step that takes a table <table:data.csv> * Check if the following users exist <table : /Users/john/work/users.csv>
7.Comments
Thisis a comment
8.Image
![Alt text](/path/to/img.jpg) ![Alt text](/path/to/img.jpg "可選的標題")
9.Link
This is [an example](http://getgauge.io "Title") inline link. [This link](http://github.com/getgauge/gauge) has no title attribute.
執行項目
經過文件執行
specs
文件夾下的specs.spec
文件gauge specs
specs
文件夾下的specs.spec
文件gauge specs/specs.spec
gauge specs-dir1/ specs-dir2/
gauge specs-dir1/example.spec specs-dir2/example2.spec
Scenario
gauge specs/example.spec:16
數字表明該secnaior所在的行,從0開始
Scenario
gauge specs-dir1/example.spec:16 specs-dir2/example.spec:18
gauge --verbose specs
經過Tags執行
以下列specification的Tags
Login specification =================== Tags: login, admin, user login Successful login scenario ------------------------- Tags: login-success, admin failed login scenario ------------------------- Tags: login-failed, admin
gauge --tag admin specs
帶有admin 的全部的或都會被執行 SpecificationScenario
Tag
執行gauge --tag "login,admin" specs
只有同時有和 Tag的或者纔會被執行loginadminSpecificationScenario
Tag
gauge --tag "user login" specs
與、或、非
運算!TagA: 執行不含有TagA的Specification或Scenario TagA & !TagB: 執行含有TagA但不含TagB的Specification或Scenario (TagA & TagB) | TagC: 執行同時含有TagA和TagB或者含有TagC的Specification或Scenario (TagA | TagB) & TagC: 執行同時含有TagA和TagC或者TagB和TagC的Specification或Scenario
Gauge中的鉤子(Hook)
Java
中的AOP(Aspect Oriented Programming)
,把Specification
或Scenario
當作一個切面,在執行以前和執行以後作一些操做* 做用於全部的specification和scenaior
//在全部的Specification執行以前執行 @BeforeSuite public void BeforeSuite() { // Code for before suite } //在全部的Specification執行以後執行 @AfterSuite public void AfterSuite() { // Code for after suite }
2.specification hook
* 做用於specification,在摸個指定的specification以前或者以後執行 //在每個Specification執行以前執行 @BeforeSpec public void BeforeSpec() { // Code for before spec } //在每個Specification執行以後執行 @AfterSpec public void AfterSpec() { // Code for after spec }
3.Scenario hook
* 做用於Scenario 在每一個Scenario以前或者以後執行 //在每個Scenario 執行以前執行 @BeforeScenario public void BeforeScenario() { // Code for before scenario } //在每個Scenario 執行以後執行 @AfterScenario public void AfterScenario() { // Code for after scenario }
4.step hook
* 做用於Scenario,在每一個scenaior以前或者以後執行 //在每個Step執行以前執行 @BeforeStep public void BeforeStep() { // Code for before step } //在每個Step執行以後執行 @AfterStep public void AfterStep() { // Code for after step }
Gauge
默認會在Scenario
執行以後清除緩存,因此會在下個Scenario
執行以前建立新的對象,該功能能夠在配置中設置清除緩存的等級