How to use test_passing_outline method in pytest-bdd

Best Python code snippet using pytest-bdd_python

test_cucumber_json.py

Source:test_cucumber_json.py Github

copy

Full Screen

...78 @scenario('test.feature', 'Failing')79 def test_failing():80 pass81 @scenario('test.feature', 'Passing outline')82 def test_passing_outline():83 pass84 """85 )86 )87 result, jsonobject = runandparse(testdir)88 assert result.ret89 expected = [90 {91 "description": "",92 "elements": [93 {94 "description": "",95 "id": "test_passing",96 "keyword": "Scenario",97 "line": 5,98 "name": "Passing",99 "steps": [100 {101 "keyword": "Given",102 "line": 6,103 "match": {"location": ""},104 "name": "a passing step",105 "result": {"status": "passed", "duration": OfType(int)},106 },107 {108 "keyword": "And",109 "line": 7,110 "match": {"location": ""},111 "name": "some other passing step",112 "result": {"status": "passed", "duration": OfType(int)},113 },114 ],115 "tags": [{"name": "scenario-passing-tag", "line": 4}],116 "type": "scenario",117 },118 {119 "description": "",120 "id": "test_failing",121 "keyword": "Scenario",122 "line": 10,123 "name": "Failing",124 "steps": [125 {126 "keyword": "Given",127 "line": 11,128 "match": {"location": ""},129 "name": "a passing step",130 "result": {"status": "passed", "duration": OfType(int)},131 },132 {133 "keyword": "And",134 "line": 12,135 "match": {"location": ""},136 "name": "a failing step",137 "result": {"error_message": OfType(str), "status": "failed", "duration": OfType(int)},138 },139 ],140 "tags": [{"name": "scenario-failing-tag", "line": 9}],141 "type": "scenario",142 },143 {144 "description": "",145 "keyword": "Scenario",146 "tags": [{"line": 14, "name": "scenario-outline-passing-tag"}],147 "steps": [148 {149 "line": 16,150 "match": {"location": ""},151 "result": {"status": "passed", "duration": OfType(int)},152 "keyword": "Given",153 "name": "type <type> and value <value>",154 }155 ],156 "line": 15,157 "type": "scenario",158 "id": "test_passing_outline[str-hello]",159 "name": "Passing outline",160 },161 {162 "description": "",163 "keyword": "Scenario",164 "tags": [{"line": 14, "name": "scenario-outline-passing-tag"}],165 "steps": [166 {167 "line": 16,168 "match": {"location": ""},169 "result": {"status": "passed", "duration": OfType(int)},170 "keyword": "Given",171 "name": "type <type> and value <value>",172 }173 ],174 "line": 15,175 "type": "scenario",176 "id": "test_passing_outline[int-42]",177 "name": "Passing outline",178 },179 {180 "description": "",181 "keyword": "Scenario",182 "tags": [{"line": 14, "name": "scenario-outline-passing-tag"}],183 "steps": [184 {185 "line": 16,186 "match": {"location": ""},187 "result": {"status": "passed", "duration": OfType(int)},188 "keyword": "Given",189 "name": "type <type> and value <value>",190 }191 ],192 "line": 15,193 "type": "scenario",194 "id": "test_passing_outline[float-1.0]",195 "name": "Passing outline",196 },197 ],198 "id": os.path.join("test_step_trace0", "test.feature"),199 "keyword": "Feature",200 "line": 2,201 "name": "One passing scenario, one failing scenario",202 "tags": [{"name": "feature-tag", "line": 1}],203 "uri": os.path.join(testdir.tmpdir.basename, "test.feature"),204 }205 ]206 assert jsonobject == expected207def test_step_trace_with_expand_option(testdir):208 """Test step trace."""209 testdir.makefile(210 ".ini",211 pytest=textwrap.dedent(212 """213 [pytest]214 markers =215 feature-tag216 scenario-outline-passing-tag217 """218 ),219 )220 testdir.makefile(221 ".feature",222 test=textwrap.dedent(223 """224 @feature-tag225 Feature: One scenario outline, expanded to multiple scenarios226 @scenario-outline-passing-tag227 Scenario: Passing outline228 Given type <type> and value <value>229 Examples: example1230 | type | value |231 | str | hello |232 | int | 42 |233 | float | 1.0 |234 """235 ),236 )237 testdir.makepyfile(238 textwrap.dedent(239 """240 import pytest241 from pytest_bdd import given, scenario242 @given('type <type> and value <value>')243 def type_type_and_value_value():244 return 'pass'245 @scenario('test.feature', 'Passing outline')246 def test_passing_outline():247 pass248 """249 )250 )251 result, jsonobject = runandparse(testdir, "--cucumber-json-expanded")252 result.assert_outcomes(passed=3)253 assert jsonobject[0]["elements"][0]["steps"][0]["name"] == "type str and value hello"254 assert jsonobject[0]["elements"][1]["steps"][0]["name"] == "type int and value 42"255 assert jsonobject[0]["elements"][2]["steps"][0]["name"] == "type float and value 1.0"256def test_converters_dict_with_expand_option(testdir):257 """Test that `--cucumber-json-expanded` works correctly when using `example_converters`."""258 testdir.makefile(259 ".feature",260 test=textwrap.dedent(261 """262 Feature: Expanded option with example converters263 Scenario: Passing outline264 Given there is an intvalue <intvalue> and stringvalue <stringvalue> and floatvalue <floatvalue>265 Examples: example1266 | intvalue | stringvalue | floatvalue |267 | 1 | hello | 1.0 |268 """269 ),270 )271 testdir.makepyfile(272 textwrap.dedent(273 """274 import pytest275 from pytest_bdd import given, scenario276 @given('there is an intvalue <intvalue> and stringvalue <stringvalue> and floatvalue <floatvalue>')277 def type_type_and_value_value():278 pass279 @scenario(280 'test.feature',281 'Passing outline',282 example_converters={"intvalue":int, "stringvalue":str, "floatvalue":float},283 )284 def test_passing_outline():285 pass286 """287 )288 )289 result, jsonobject = runandparse(testdir, "--cucumber-json-expanded")290 assert result.ret == 0291 expanded_step_name = jsonobject[0]["elements"][0]["steps"][0]["name"]...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pytest-bdd automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful