-
Notifications
You must be signed in to change notification settings - Fork 0
How to use allure reports
If you don't know, what Allure is, please see example page
More information on official documentation Allure
AWARE! You may need to install JAVA application
- Linux
For Debian-based repositories a PPA is provided:
sudo apt-add-repository ppa:qameta/allure
sudo apt-get update
sudo apt-get install allure
- Mac OS X
For Mas OS, automated installation is available via Homebrew
brew install allure
- Windows
For Windows, Allure is available from the Scoop command line-installer.
To install Allure, download and install Scoop and then execute in the Powershell:
scoop install allure
It's possible to group your test suites by custom features and your test cases by stories (like in BDD)
- To add a test suite to custom feature you need to add
@pytest.allure.feature('[Feature_Name]')
before your TestClass
@pytest.allure.feature('Google search')
class TestGoogle(TestBase):
@classmethod
- To add test case to custom story in feature you need to add
@pytest.allure.story('[Scenario_name]')
before your [test_method]
@pytest.allure.story('Check search works correctly')
def testCheckSearch(self):
self.assertTrue(self.google_page.search_field_present()) # Check search field present
self.google_page.search_text() # Use search
self.assertTrue(self.google_page.check_page_title_equal_search()) # Check search works correctly
- To add custom severity to your test case you need to add @pytest.allure.severity(pytest.allure.severity_level.CRITICAL) before your [test_method]
@pytest.allure.severity(pytest.allure.severity_level.CRITICAL)
@pytest.allure.story('Check search works correctly')
def testCheckSearch(self):
self.assertTrue(self.google_page.search_field_present()) # Check search field present
self.google_page.search_text() # Use search
self.assertTrue(self.google_page.check_page_title_equal_search()) # Check search works correctly
Steps can be added to your test report to separate different methods and actions in the report. For example separate login and search methods.
- To add custom Step to the test method you need to go to your page test methods and add
@pytest.allure.step('[step_name]')
before [test_method]
To add important link to your test, you need to use decorator @pytest.allure.link.
@pytest.allure.link(MAIN_URL + '[link]', name='Ticket creation page link')
- '[link]' is the link after main url (for example MAIN_URL = https://www.google.com and '[link]' = /search so in result we will get
https://www.google.com/search
link in the Allure report) - name= is the name of a hyperlink in the report.
To add a link to the test case of your test, you need to use decorator @pytest.allure.testcase.
@pytest.allure.testcase('https://test_case.com', name=TEST_CASE)
For run tests using Allure need to do next:
- Open project in PyCharm
- Find execute_selenium_tests.sh file (if OS is Mac)
- Find execute_selenium_tests.cmd file (if OS is Windows)
- Right click on it and click Run (Run cmd is Windows)
An executed file will run all the tests in tests folder and create allure report and generate it into the browser.
To run exact test suite, you need to change py.test ~/PycharmProjects/automated-tests/tests/
row to py.test ~/PycharmProjects/automated-tests/tests/test_google.py
To run tests with specific severity you need to add --allure_severities=critical,blocker
property to the execute path in execute_selenium_tests.sh file
py.test ~/PycharmProjects/automated-tests/tests --allure_severities=critical,blocker
To run tests from specific feature you need to add py.test my_tests/ --allure_features=feature1
property to the execute path in execute_selenium_tests.sh file
py.test ~/PycharmProjects/automated-tests/tests --allure_features=feature1
Screenshots already attach to report when the test fails.
But if you want to add specific attachment to the report, you need to add allure.attach('[file_name]', [file], type=AttachmentType.PNG)
- TEXT
- HTML
- XML
- PNG
- JPG
- JSON
- OTHER