Skip to content

Commit 886e0b7

Browse files
committed
Add an example of failing to validate features
1 parent abbac29 commit 886e0b7

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

README.rst

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,63 @@ specified either by index (from 0) or by name.
160160
If your feature includes multiple scenarios with the same name, all will be
161161
run when that name is given. Names with a trailing period can be specified with
162162
or without the trailing period.
163+
164+
Validating Tests
165+
----------------
166+
167+
You can use the ``--planterbox-check-only`` flag to verify that your features
168+
are correct without running them::
169+
170+
nose2 --planterbox-check-only planterbox.tests.test_feature
171+
172+
----------------------------------------------------------------------
173+
Ran 0 tests in 0.000s
174+
175+
OK
176+
177+
While a failure would produce a traceback::
178+
179+
nose2 --planterbox-check-only planterbox.tests.test_feature
180+
Traceback (most recent call last):
181+
File "planterbox_ve/bin/nose2", line 11, in <module>
182+
sys.exit(discover())
183+
File "nose2/main.py", line 306, in discover
184+
return main(*args, **kwargs)
185+
File "nose2/main.py", line 100, in __init__
186+
super(PluggableTestProgram, self).__init__(**kw)
187+
File "/opt/python/lib/python3.6/unittest/main.py", line 94, in __init__
188+
self.parseArgs(argv)
189+
File "nose2/main.py", line 133, in parseArgs
190+
self.createTests()
191+
File "nose2/main.py", line 258, in createTests
192+
self.testNames, self.module)
193+
File "nose2/loader.py", line 68, in loadTestsFromNames
194+
for name in event.names]
195+
File "nose2/loader.py", line 68, in <listcomp>
196+
for name in event.names]
197+
File "nose2/loader.py", line 83, in loadTestsFromName
198+
result = self.session.hooks.loadTestsFromName(event)
199+
File "nose2/events.py", line 225, in __call__
200+
result = getattr(plugin, self.method)(event)
201+
File "nose2/plugins/loader/discovery.py", line 247, in loadTestsFromName
202+
return Discoverer.loadTestsFromName(self, event)
203+
File "nose2/plugins/loader/discovery.py", line 84, in loadTestsFromName
204+
self._find_tests_in_module(event, module, top_level_dir))
205+
File "nose2/plugins/loader/discovery.py", line 229, in _find_tests_in_module
206+
event, full_path, top_level_dir):
207+
File "nose2/plugins/loader/discovery.py", line 161, in _find_tests_in_dir
208+
event, path, entry_path, top_level):
209+
File "nose2/plugins/loader/discovery.py", line 176, in _find_tests_in_file
210+
result = self.session.hooks.handleFile(evt)
211+
File "nose2/events.py", line 225, in __call__
212+
result = getattr(plugin, self.method)(event)
213+
File "planterbox/planterbox/plugin.py", line 106, in handleFile
214+
feature_path=feature_path,
215+
File "planterbox/planterbox/plugin.py", line 75, in makeSuiteFromFeature
216+
config=self.config,
217+
File "planterbox/planterbox/feature.py", line 81, in __init__
218+
self.check_scenarios()
219+
File "planterbox/planterbox/feature.py", line 227, in check_scenarios
220+
raise UnmatchedStepException("Unmatched steps:\n" + '\n'.join(unmatched))
221+
planterbox.exceptions.UnmatchedStepException: Unmatched steps:
222+
Given I bad 1 and 1

0 commit comments

Comments
 (0)