export test case file and test cycle file for teko-tool push to jira
Project description
EXPORT TEST CASE AND TEST CYCLE TO FILE
Push test to Jira
1. Requirement
- Python 3
- pytest package
2. Set up
pip install --upgrade teko-export-test
- Add to test setting
pytest_plugins = ['export_test_jira.tool']
. Example, add toconftest.py
: - Note: you can define test script by many ways
- use
plan
decorator/keyword - use
scripts
decorator/keyword
- use
3. Write test function, Example
- To import decorator:
from export_test_jira.wraper import jira_test
- To use test script STEP_BY_STEP:
from export_test_jira.models.test_step import TestStep
# coding=utf-8
from export_test_jira.wraper import jira_test
from export_test_jira.models.test_step import TestStep as Step
pytest_plugins = ["export_test_jira.tool"]
# 1 : define test_case by decorator
@jira_test(
issue_links=['TESTING-9'],
name='Result=False when duplicate brand',
objective='Make sure that not allow create message when exists msg with same brand',
scripts=[
Step(
description='Create a new campaign',
expected_result='create campaign success',
test_data='None'
),
Step(
description='Get a template from User Notification services',
expected_result='get template success',
test_data='None'
),
Step(
description='Create 2 message with a template_id and XXX brand for this campaign',
expected_result='Conflict error',
test_data='''campaign_id = campaign.id,
msg_template_id = template.id ,
msg_params= fixed, brand = XXX'''
)
]
)
def test_create_campaign_msg_fail_when_duplicate_brand():
print('Processing')
assert 409 == 409
@jira_test(
issue_links=['TESTING-9', 'TESTING-10'],
objective='Make sure that success when input is valid',
confluence_links=['https://confluence.teko.vn/display/EP/Archive',
'https://confluence.teko.vn/display/EP/Data+Flow+Diagrams'],
web_links=['dungntc.com', 'google.com'],
folder='/Mkt Portal Test/Campaign msg test',
plan='Create fake campaign and get a fake template. Then call api create message. Make sure msg created in database'
)
def test_create_campaign_msg_success():
print('Processing')
assert 409 == 409
# 2 : define test_case by docstring
def test_create_campaign_msg_fail_when_duplicate_brand_docstring():
"""
::JIRA
issueLinks: TESTING-9
objective: Make sure that not allow create message when exists msg with same brand
precondition: Has an message template from User Notification service
priority: Normal
scripts:
description: Create a new campaign
expectedResult: create campaign success
testData: None
description: Get a template from User Notification services
expectedResult: get template success
testData: None
description: Create new message with VNSHOP brand for this campaign
expectedResult: create message with VNSHOP brand success
testData: campaign_id = campaign.id, msg_template_id = template.id ,
msg_params= fixed, brand = XXX
description: Create other message with a template_id and VNSHOP brand for this campaign
expectedResult: create message fail with conflict error
testData: campaign_id = campaign.id, msg_template_id = template.id ,
msg_params= fixed, brand = XXX
description: Make sure msg not created in database
expectedResult: number of msg in db is 1
testData: None
"""
print('Processing')
assert 409 == 409
def test_create_campaign_msg_success_docstring():
"""
::JIRA
name: Result=success when input is valid - DOCSTRING
issueLinks: TESTING-9, TESTING-10
objective: Make sure that success when input is valid
precondition: Has an message template from User Notification service
confluenceLinks: https://confluence.teko.vn/display/EP/Archive, https://confluence.teko.vn/display/EP/Data+Flow+Diagrams
webLinks: Dungntc.com, google.com
folder: /Mkt Portal Test/Campaign msg test
priority: Normal
plan: Create fake campaign and get a fake template. Then call api create message. Make sure msg created in database
::END_JIRA
other comment ....
"""
print('Processing')
assert 409 == 409
4 Maybe you need push test to Jira with teko-tool, this is example gitlab-ci.yml
test:unittest:
stage: test
...
variables:
JIRA_TEST_CASE_ARTIFACT: test_case.json
JIRA_TEST_CYCLE_ARTIFACT: test_cycle.json
artifacts:
paths:
- $JIRA_TEST_CASE_ARTIFACT
- $JIRA_TEST_CYCLE_ARTIFACT
expire_in: 1 week
allow_failure: false
- Enviroment:
$JIRA_TEST_CASE_ARTIFACT
: test_case file path, default is test_case.json$JIRA_TEST_CYCLE_ARTIFACT
: test_cycle file path, default is test_cycle.json- Optional:
$ENV
or$ENVIRONMENT
for test cycle env. Default, detect env from$CI_COMMIT_BRANCH
report:push-test:
stage: report
image: python:3.7-slim
variables:
JIRA_TEST_CASE_ARTIFACT: test_case.json
JIRA_TEST_CYCLE_ARTIFACT: test_cycle.json
JIRA_PROJECT_KEY: TESTING
JIRA_SERVER: jira.teko.vn
JIRA_USERNAME: changeme
JIRA_PASSWORD: changeme
CONFLUENCE_USERNAME: changeme
CONFLUENCE_PASSWORD: changeme
script:
- pip install --upgrade --cache-dir=.pip teko-cli
- teko jira create-tests $JIRA_TEST_CASE_ARTIFACT
- teko jira create-cycle $JIRA_TEST_CYCLE_ARTIFACT
cache:
key: pip-cache
paths: [ .pip ]
allow_failure: true
when: always
- Enviroment:
$JIRA_TEST_CASE_ARTIFACT
: test_case file path, default is test_case.json$JIRA_TEST_CYCLE_ARTIFACT
: test_cycle file path, default is test_cycle.json$JIRA_SERVER
: jira.teko.vn$JIRA_PROJECT_KEY
: TESTING$JIRA_USERNAME
: tekobot$JIRA_PASSWORD
: *****$CONFLUENCE_USERNAME
: tekobot$CONFLUENCE_PASSWORD
: *****
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
teko-export-test-0.0.5.tar.gz
(7.7 kB
view hashes)
Built Distribution
Close
Hashes for teko_export_test-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be50dc951ee15e0b403bd76a980a9168116cee78d1b8cb6a878bea848fb9bbe1 |
|
MD5 | 81518aee9bab106c9d95bf67f554d25e |
|
BLAKE2b-256 | 6be4b61c85f9f58181bedeee6c50144e43c90d920095adec9da268b9dc07ba1f |