Skip to main content

conduct BDD by excel feature files

Project description

Use Excel file as BDD feature file, get example data from excel files, support automation tests

V1.4.9 changes: columns are not selected after a blank header is present in bdd format. behavior is removed, use excelbdd instead, as below. old: from excelbdd.behavior import get_example_list new: from excelbdd import excelbdd

#pip install excelbdd
import pytest
from excelbdd import excelbdd
import FizzBuzz

excelBDDFile = "path of excel file" 
@pytest.mark.parametrize("HeaderName, Number1, Output1, Number2, Output2, Number3, Output3, Number4, Output4",
                        excelbdd.get_example_list(excelBDDFile,"FizzBuzz"))
def test_FizzBuzz(HeaderName, Number1, Output1, Number2, Output2, Number3, Output3, Number4, Output4):
    assert FizzBuzz.handle(Number1) == Output1
    assert FizzBuzz.handle(Number2) == Output2
    assert FizzBuzz.handle(Number3) == Output3
    assert FizzBuzz.handle(Number4) == Output4

Get data from table in Excel, similar to get from csv file

from excelbdd import excelbdd
@pytest.mark.parametrize("Header01, Header02, Header03, Header04, Header05, Header06, Header07, Header08",
                         excelbdd.get_example_table(excelBDDFile, "DataTable4"))
def test_get_example_tableB(Header01, Header02, Header03, Header04, Header05, Header06, Header07, Header08):
    print(Header01, Header02, Header03, Header04, Header05, Header06, Header07, Header08)
    # add test code here

"Specification by testcase" is supported. the bdd excel files can be regarded as the test reports. The test format in excel is detected automatically, only extra parameters(expected, test result) are needed to take into test method.

Python unittest is also supported by ExcelBDD.

import unittest
from excelbdd import excelbdd
from parameterized import parameterized

class ExcelBDDTest(unittest.TestCase):
    @parameterized.expand(excelbdd.get_example_list(excelBDDFile))
    def test_get_example_tableB(self, HeaderName, ParamName1, ParamName2, ParamName3, ParamName4):
        print(HeaderName, ParamName1, ParamName2, ParamName3, ParamName4)
        # add test code here
        self.assertEqual(ParamName1, "P1")
        self.assertEqual(ParamName3, None)

more information at ExcelBDD Python Guideline

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

excelbdd-1.4.9.tar.gz (5.0 kB view hashes)

Uploaded Source

Built Distribution

excelbdd-1.4.9-py3-none-any.whl (3.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page