Testing web apps with Go
Install app using git clone command
After install build app with go build
In app directory create a config folder.
App runs from command line:
> ./appname [parameters]
Available command line parameters:
-config- mandatory, name of config, which is path in app's/configpath-type- optional, type of config file, currently allowed types (jsonandsitemapxml),jsonis default,-filename- optional, custom name of config file without extension, by default it's"conf"-verbose- optional, output more / less data when tests are run, available values: (n,y),yby default
Examples:
- Test urls from
./config/mysite/conf.jsonconfig file
> ./appname -config=mysite
- Test urls from
./config/myothersite/conf.xmlxml-config file
> ./appname -config=myothersite -type=sitemapxml
- Test urls from
./config/mysite/conf.jsonconfig file and output only fail messages
> ./appname -config=mysite -verbose=n
- Test urls from
./config/mysite/urls.jsonconfig file
> ./appname -config=mysite -filename=urls
App supports config files in json and xml formats.
json format is as follows:
{
"protocol": "https",
"domain": "www.mysite.com",
"checkUrls": true,
"urls": [
{
"url": "/url/here",
"statusCode": 200,
"skipUrlsCheck": false,
"findElements": []
},
{
"url": "/url/here",
"statusCode": 200,
"findElements": [
{
"def": ".some-class",
"countType": "eq",
"count": 3
}
]
}
]
}
Where:
-
protocolcan be eitherhttporhttps -
checkUrlsoption tells to check all local links on pages -
skipUrlsCheckcancelscheckUrlsand all links on this concrete page will not be checked -
findElementswill find on this concrete page elements defined by following objects -
defdefinition of collection objects to search (like jQuery selectors) -
countType- mode of comparing collection size againstcount, available modes areeq- equalsgt- greater thangte- greater than or equalslt- less thanlte- less than or equalsne- not equals
-
count- expected collection size
xml format fully supports google sitemap xml, but has less oppotunities than json.