• This repository has been archived on 14/Jan/2019
  • Stars
    star
    171
  • Rank 222,266 (Top 5 %)
  • Language
    Python
  • License
    Other
  • Created almost 11 years ago
  • Updated almost 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Deprecated, please use https://github.com/allure-framework/allure-python instead

[DEPRICATED]

Please follow https://github.com/allure-framework/allure-python

Allure Pytest Adaptor

Join the chat at https://gitter.im/allure-framework/allure-core Build Status Release Status Downloads

This repository contains a plugin for py.test which automatically prepares input data used to generate Allure Report. Note: this plugin currently supports only Allure 1.4.x series.

Installation and Usage

py.test --alluredir [path_to_report_dir]
# WARNING [path_to_report_dir] will be purged at first run

This plugin gets automatically connected to py.test via entry point if installed.

Connecting to IDE:

pytest_plugins = 'allure.pytest_plugin',\

Allure Features

Attachments

To attach some content to test report:

import allure

def test_foo():
    allure.attach('my attach', 'Hello, World')

Steps

To divide a test into steps:

import pytest

def test_foo():
    with pytest.allure.step('step one'):
        # do stuff

    with pytest.allure.step('step two'):
        # do more stuff

Can also be used as decorators. By default step name is generated from method name:

import pytest

@pytest.allure.step
def make_test_data_foo():
    # do stuff

def test_foo():
    assert make_some_data_foo() is not None

@pytest.allure.step('make_some_data_foo')
def make_some_data_bar():
    # do another stuff

def test_bar():
    assert make_some_data_bar() is not None

Steps can also be used without pytest. In that case instead of pytest.allure.step simply use allure.step:

import allure

@allure.step('some operation')
def do_operation():
    # do stuff

allure.step decorator supports step name formatting with function parameters:

import allure

@allure.step('some operation for bar={0}')
def do_operation(bar):
    # do stuff

def test_foo():
    assert do_operation('abcdef')

The step in the latter case will have name some operation for bar=abcdef. Formatting is done via python's built-in string.format and supports it's options. Arguments are passed to format method in the same way they are passed to the decorated function.

Steps support is limited when used with fixtures.

Severity

Any test, class or module can be marked with different severity:

import pytest

@pytest.allure.severity(pytest.allure.severity_level.MINOR)
def test_minor():
    assert False


@pytest.allure.severity(pytest.allure.severity_level.CRITICAL)
class TestBar:

    # will have CRITICAL priority
    def test_bar(self):
        pass

    # will have BLOCKER priority via a short-cut decorator
    @pytest.allure.BLOCKER
    def test_bar(self):
        pass

To run tests with concrete priority:

py.test my_tests/ --allure_severities=critical,blocker

Issues

Issues can be set for test.

import pytest

@pytest.allure.issue('http://jira.lan/browse/ISSUE-1')
def test_foo():
    assert False


import allure

@allure.issue('http://jira.lan/browse/ISSUE-2')
class TestBar:

    # test will have ISSUE-2, ISSUE-3 and ISSUE-4 label
    @allure.issue('http://jira.lan/browse/ISSUE-3')
    def test_bar1(self):
        # You can use this feature like a function inside the test
        allure.dynamic_issue('http://jira.lan/browse/ISSUE-4')
        pass

    # test will have only ISSUE-2 label
    def test_bar2(self):
        pass

Test cases

Test cases links can be set for test also.

import pytest

@pytest.allure.testcase('http://my.tms.org/TESTCASE-1')
def test_foo():
    assert False


import allure

@allure.testcase('http://my.tms.org/browse/TESTCASE-2')
class TestBar:

    # test will have TESTCASE-2 and TESTCASE-3 label
    @allure.testcase('TESTCASE-3')
    def test_bar1(self):
        pass

    # test will have only TESTCASE-2 label
    def test_bar2(self):
        pass

Features & Stories

Feature and Story can be set for test.

import allure


@allure.feature('Feature1')
@allure.story('Story1')
def test_minor():
    assert False


@allure.feature('Feature2')
@allure.story('Story2', 'Story3')
@allure.story('Story4')
class TestBar:

    # will have 'Feature2 and Story2 and Story3 and Story4'
    def test_bar(self):
        pass

To run tests by Feature or Story:

py.test my_tests/ --allure_features=feature1,feature2
py.test my_tests/ --allure_features=feature1,feature2 --allure_stories=story1,story2

Environment Parameters

You can provide test environment parameters such as report name, browser or test server address to allure test report.

import allure
import pytest


def pytest_configure(config):
    allure.environment(report='Allure report', browser=u'Я.Браузер')


@pytest.fixture(scope="session")
def app_host_name():
    host_name = "my.host.local"
    allure.environment(hostname=host_name)
    return host_name


@pytest.mark.parametrize('country', ('USA', 'Germany', u'Россия', u'Япония'))
def test_minor(country):
    allure.environment(country=country)
    assert country

More details about allure environment you can know from documentation.

Development

Use allure.common.AllureImpl class to bind your logic to this adapter.

More Repositories

1

allure2

Allure Report is a flexible, lightweight multi-language test reporting tool. It provides clear graphical reports and allows everyone involved in the development process to extract the maximum of information from the everyday testing process
Java
4,160
star
2

allure-python

Allure integrations for Python test frameworks
Python
725
star
3

allure1

Allure 1 isn't supported any more, please consider using Allure 2 https://github.com/allure-framework/allure2 instead
Java
712
star
4

allure-java

Allure integrations for Java test frameworks
Java
357
star
5

allure-js

Allure integrations for JavaScript test frameworks
TypeScript
225
star
6

allure-csharp

Allure integrations for C# test frameworks
C#
107
star
7

allure-maven

Maven plugin generating Allure report from test results
Java
96
star
8

allure-gradle

Allure Gradle Plugin
Kotlin
86
star
9

allure-android

Android library for generating instrumentation reports in Allure format
Kotlin
66
star
10

allure-docs

Allure Framework documentation
JavaScript
61
star
11

allure-phpunit

Allure integrations for PHP test frameworks: PHPUnit
PHP
60
star
12

allure-ruby

Allure integrations for Ruby test frameworks
Ruby
58
star
13

allure-kotlin

Allure integrations for test frameworks targeting Kotlin and Java with 1.6 source compatibility.
Kotlin
56
star
14

allure-codeception

Codeception framework adapter for Allure
PHP
51
star
15

allure-mocha

Deprecated, use https://github.com/allure-framework/allure-js instead
JavaScript
45
star
16

allure-npm

NPM wrapper for Allure commandline
PowerShell
37
star
17

allure-teamcity

Teamcity CI plugin allowing to generate Allure Report as build artifact
Java
37
star
18

allure-cucumber

Deprecated, use https://github.com/allure-framework/allure-ruby instead
Gherkin
36
star
19

allure-jasmine

Deprecated, use https://github.com/allure-framework/allure-js instead
JavaScript
35
star
20

allure-php-api

PHP API for Allure Framework
PHP
33
star
21

allurectl

Allure TestOps Command line tool
32
star
22

allure-rspec

Deprecated, use https://github.com/allure-framework/allure-ruby instead
Ruby
28
star
23

allure-js-commons

Deprecated, use https://github.com/allure-framework/allure-js instead
JavaScript
27
star
24

allure-bamboo

Allure plugin for Atlassian Bamboo
Java
26
star
25

allure-mstest

Deprecated, since native support for TRX results format was introduced in Allure 2
C#
19
star
26

allure-cucumberjvm

Deprecated, use https://github.com/allure-framework/allure-java instead
Java
16
star
27

allure-cucumberjs

Deprecated, use https://github.com/allure-framework/allure-js instead
JavaScript
15
star
28

allure-nunit2

Deprecated, use https://github.com/allure-framework/allure-csharp instead
C#
15
star
29

allure-nose

Deprecated, use https://github.com/allure-framework/allure-python instead
Python
15
star
30

allure-ruby-commons

Deprecated, use https://github.com/allure-framework/allure-ruby instead
Ruby
14
star
31

allure-behat

Allure Adapter for Behat framework
PHP
13
star
32

setup-allurectl

Set up your GitHub Actions workflow with a specific version of allurectl
TypeScript
13
star
33

allure-scalatest

Deprecated, use https://github.com/allure-framework/allure-java instead
Scala
13
star
34

allure-demo

The demo report
Java
11
star
35

allure-csharp-commons

Deprecated, use https://github.com/allure-framework/allure-csharp instead
C#
10
star
36

allure-karma

Allure adapter to karma test runner
JavaScript
9
star
37

allure-vstest

C#
8
star
38

allure-php-commons2

Allure integrations for PHP test frameworks: Commons Module
PHP
8
star
39

allure-debian

Debian (Ubuntu) package configuration for Allure Framework parts
Shell
7
star
40

allure2-model

Deprecated, use https://github.com/allure-framework/allure-java instead
Java
5
star
41

allure-spock

Deprecated, use https://github.com/allure-framework/allure-java instead
Groovy
5
star
42

allure-idea

Java
5
star
43

allure-vsts

Archived, please follow https://github.com/orgs/allure-framework/discussions
HTML
4
star
44

allure1-model

Java
3
star
45

allure-specs

Allure Adapter for Specs framework
Scala
3
star
46

.github

Organisation profile
1
star