Introduction
Hi everyone. I work as QA engineer in an IT company. I am a team leader of autotesters. We automatize UI and API tests. We run thousands of test scripts every day. Our scripts are written on python.
Pythons standard libraries are very good, but developing and maintaining scripts take a lot of time. We need to quickly develop, launch and provide test result to the customer.
In the work of a tester, it is very important to provide a report with test result to the customer. We use Allure for this.
To run the test scripts, we use CI/CD (Jenkins). After passing the test scripts, a report with the test results is automatically generated.
The anna library was developed for quickly development and report generation.
Installation
pip install anna-api-test-framework
How to use
Import the library first:
from anna import Actions, Report, Asserts
- Actions contains methods for executing http requests. All request and response data is automatically added to the report.
action = Action(url=url)
response = action.request(method=method)
It's very convenient.
- Report contains methods for added important information to the report. Like steps, title, epic, links, another data and etc.
@Report.epic('Simple tests')
@Report.story('Tests google')
@Report.testcase('https://www.google.com', 'Google')
@Report.link('https://www.google.com', 'Just another link')
class TestExample:
@Report.title('Simple test google')
@Report.severity('CRITICAL')
def test_simple_request(self):
url = 'https://google.com'
method = 'GET'
want = 200
Report.description(url=url, method=method, other='other information')
- Assert contains methods for checking
with Report.step('Checking response'):
Assert.compare(
variable_first=want,
comparison_sign='==',
variable_second=got,
text_error='Response status code is not equal to expected'
)
How to run tests
Use the following command:
pytest alluredir="./results"
This command runs tests from the current directory and saves the test results to the results
directory
How to generate report
To do this, you need an installed Allure.
Use the following command to generate report:
allure generate "./results" -c -o "./report"
The report will be generated in the report
directory
Ho to open report
Use the following command:
allure open "./report"
You can see the following output:
Starting web server...
2022-04-06 12:58:39.896:INFO::main: Logging initialized @1655ms to org.eclipse.jetty.util.log.StdErrLog
Server started at <http://172.31.22.186:61080/>. Press <Ctrl+C> to exit
If you follow the link, the generated report will open
Conclusion
This library helps you quickly develop test scripts and data for reports.
Thank you for your attention!πππ
**this is my first article, do not judge strictly
Top comments (0)