mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-03 06:49:38 +08:00
add jenkins-mail-py to support mail test result
This commit is contained in:
42
README.md
42
README.md
@@ -14,7 +14,7 @@ Take full reuse of Python's existing powerful libraries: [`Requests`][requests],
|
|||||||
- Supports `function`/`variable`/`extract`/`validate` mechanisms to create full test scenarios.
|
- Supports `function`/`variable`/`extract`/`validate` mechanisms to create full test scenarios.
|
||||||
- Testcases can be run in diverse ways, with single testset, multiple testsets, or entire project folder.
|
- Testcases can be run in diverse ways, with single testset, multiple testsets, or entire project folder.
|
||||||
- Test report is concise and clear, with detailed log records. See [`PyUnitReport`][PyUnitReport].
|
- Test report is concise and clear, with detailed log records. See [`PyUnitReport`][PyUnitReport].
|
||||||
- Perfect combination with [Jenkins][Jenkins], running continuous integration test and production environment monitoring.
|
- Perfect combination with [Jenkins][Jenkins], running continuous integration test and production environment monitoring. Send mail notification with [`jenkins-mail-py`][jenkins-mail-py].
|
||||||
- With reuse of [`Locust`][Locust], you can run performance test without extra work.
|
- With reuse of [`Locust`][Locust], you can run performance test without extra work.
|
||||||
- It is extensible to facilitate the implementation of web platform with [`Flask`][flask] framework.
|
- It is extensible to facilitate the implementation of web platform with [`Flask`][flask] framework.
|
||||||
|
|
||||||
@@ -38,16 +38,21 @@ To ensure the installation or upgrade is successful, you can execute command `at
|
|||||||
|
|
||||||
```text
|
```text
|
||||||
$ ate -V
|
$ ate -V
|
||||||
0.3.0
|
0.3.1
|
||||||
```
|
```
|
||||||
|
|
||||||
Execute the command `ate -h` to view command help.
|
Execute the command `ate -h` to view command help.
|
||||||
|
|
||||||
```text
|
```text
|
||||||
$ ate -h
|
$ ate -h
|
||||||
usage: main.py [-h] [-V] [--log-level LOG_LEVEL] [--report-name REPORT_NAME]
|
usage: ate [-h] [-V] [--log-level LOG_LEVEL] [--report-name REPORT_NAME]
|
||||||
[--failfast]
|
[--failfast] [--mailgun-api-id MAILGUN_API_ID]
|
||||||
[testset_paths [testset_paths ...]]
|
[--mailgun-api-key MAILGUN_API_KEY] [--email-sender EMAIL_SENDER]
|
||||||
|
[--email-recepients EMAIL_RECEPIENTS] [--mail-subject MAIL_SUBJECT]
|
||||||
|
[--mail-content MAIL_CONTENT] [--jenkins-job-name JENKINS_JOB_NAME]
|
||||||
|
[--jenkins-job-url JENKINS_JOB_URL]
|
||||||
|
[--jenkins-build-number JENKINS_BUILD_NUMBER]
|
||||||
|
[testset_paths [testset_paths ...]]
|
||||||
|
|
||||||
Api Test Engine.
|
Api Test Engine.
|
||||||
|
|
||||||
@@ -62,6 +67,24 @@ optional arguments:
|
|||||||
--report-name REPORT_NAME
|
--report-name REPORT_NAME
|
||||||
Specify report name, default is generated time.
|
Specify report name, default is generated time.
|
||||||
--failfast Stop the test run on the first error or failure.
|
--failfast Stop the test run on the first error or failure.
|
||||||
|
--mailgun-api-id MAILGUN_API_ID
|
||||||
|
Specify mailgun api id.
|
||||||
|
--mailgun-api-key MAILGUN_API_KEY
|
||||||
|
Specify mailgun api key.
|
||||||
|
--email-sender EMAIL_SENDER
|
||||||
|
Specify email sender.
|
||||||
|
--email-recepients EMAIL_RECEPIENTS
|
||||||
|
Specify email recepients.
|
||||||
|
--mail-subject MAIL_SUBJECT
|
||||||
|
Specify email subject.
|
||||||
|
--mail-content MAIL_CONTENT
|
||||||
|
Specify email content.
|
||||||
|
--jenkins-job-name JENKINS_JOB_NAME
|
||||||
|
Specify jenkins job name.
|
||||||
|
--jenkins-job-url JENKINS_JOB_URL
|
||||||
|
Specify jenkins job url.
|
||||||
|
--jenkins-build-number JENKINS_BUILD_NUMBER
|
||||||
|
Specify jenkins build number.
|
||||||
```
|
```
|
||||||
|
|
||||||
## Write testcases
|
## Write testcases
|
||||||
@@ -143,6 +166,12 @@ If you want to run testsets of a whole project, you can achieve this goal by spe
|
|||||||
$ ate testcases_folder_path
|
$ ate testcases_folder_path
|
||||||
```
|
```
|
||||||
|
|
||||||
|
When you do continuous integration test or production environment monitoring with `Jenkins`, you may need to send test result notification. For instance, you can send email with mailgun service as below.
|
||||||
|
|
||||||
|
```text
|
||||||
|
$ ate filepath/testcase.yml --mailgun-api-id samples.mailgun.org --mailgun-api-key key-3ax6xnjp29jd6fds4gc373sgvjxteol0 --email-sender excited@samples.mailgun.org --email-recepients test@email.com --jenkins-job-name demo-smoketest --jenkins-job-url http://test.debugtalk.com/job/demo-smoketest/ --jenkins-build-number 69
|
||||||
|
```
|
||||||
|
|
||||||
## Supported Python Versions
|
## Supported Python Versions
|
||||||
|
|
||||||
Python `2.7`, `3.3`, `3.4`, `3.5`, and `3.6`.
|
Python `2.7`, `3.3`, `3.4`, `3.5`, and `3.6`.
|
||||||
@@ -162,4 +191,5 @@ Python `2.7`, `3.3`, `3.4`, `3.5`, and `3.6`.
|
|||||||
[Locust]: http://locust.io/
|
[Locust]: http://locust.io/
|
||||||
[flask]: http://flask.pocoo.org/
|
[flask]: http://flask.pocoo.org/
|
||||||
[PyUnitReport]: https://github.com/debugtalk/PyUnitReport
|
[PyUnitReport]: https://github.com/debugtalk/PyUnitReport
|
||||||
[Jenkins]: https://jenkins.io/index.html
|
[Jenkins]: https://jenkins.io/index.html
|
||||||
|
[jenkins-mail-py]: https://github.com/debugtalk/jenkins-mail-py.git
|
||||||
@@ -1 +1 @@
|
|||||||
__version__ = '0.3.0'
|
__version__ = '0.3.1'
|
||||||
@@ -28,6 +28,12 @@ def main():
|
|||||||
'--failfast', action='store_true', default=False,
|
'--failfast', action='store_true', default=False,
|
||||||
help="Stop the test run on the first error or failure.")
|
help="Stop the test run on the first error or failure.")
|
||||||
|
|
||||||
|
try:
|
||||||
|
from jenkins_mail_py import MailgunHelper
|
||||||
|
mailer = MailgunHelper(parser)
|
||||||
|
except ImportError:
|
||||||
|
mailer = None
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.version:
|
if args.version:
|
||||||
@@ -69,4 +75,7 @@ def main():
|
|||||||
if len(result.successes) != result.testsRun:
|
if len(result.successes) != result.testsRun:
|
||||||
flag = "FAILED"
|
flag = "FAILED"
|
||||||
|
|
||||||
|
if mailer and mailer.config_ready:
|
||||||
|
mailer.send_mail(flag, content=results)
|
||||||
|
|
||||||
return flag, results
|
return flag, results
|
||||||
|
|||||||
@@ -4,3 +4,4 @@ PyYAML
|
|||||||
coveralls
|
coveralls
|
||||||
coverage
|
coverage
|
||||||
-e git+https://github.com/debugtalk/PyUnitReport.git#egg=PyUnitReport
|
-e git+https://github.com/debugtalk/PyUnitReport.git#egg=PyUnitReport
|
||||||
|
-e git+https://github.com/debugtalk/jenkins-mail-py.git#egg=jenkins-mail-py
|
||||||
|
|||||||
8
setup.py
8
setup.py
@@ -13,7 +13,7 @@ with open('README.md') as f:
|
|||||||
setup(
|
setup(
|
||||||
name='ApiTestEngine',
|
name='ApiTestEngine',
|
||||||
version=version,
|
version=version,
|
||||||
description='An API test engine.',
|
description='API test engine.',
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
author='Leo Lee',
|
author='Leo Lee',
|
||||||
author_email='mail@debugtalk.com',
|
author_email='mail@debugtalk.com',
|
||||||
@@ -27,10 +27,12 @@ setup(
|
|||||||
"PyYAML",
|
"PyYAML",
|
||||||
"coveralls",
|
"coveralls",
|
||||||
"coverage",
|
"coverage",
|
||||||
"PyUnitReport"
|
"PyUnitReport",
|
||||||
|
"jenkins-mail-py"
|
||||||
],
|
],
|
||||||
dependency_links=[
|
dependency_links=[
|
||||||
"git+https://github.com/debugtalk/PyUnitReport.git#egg=PyUnitReport"
|
"git+https://github.com/debugtalk/PyUnitReport.git#egg=PyUnitReport",
|
||||||
|
"git+https://github.com/debugtalk/jenkins-mail-py.git#egg=jenkins-mail-py"
|
||||||
],
|
],
|
||||||
classifiers=[
|
classifiers=[
|
||||||
"Development Status :: 3 - Alpha",
|
"Development Status :: 3 - Alpha",
|
||||||
|
|||||||
Reference in New Issue
Block a user