Skip to content

Commit a3919f0

Browse files
committed
Add unit test for skipped step processing
Signed-off-by: Chad Wilson <[email protected]>
1 parent 62dacbe commit a3919f0

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/test_processor.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from getgauge import processor
77
from getgauge import static_loader as loader
8+
from getgauge.exceptions import SkipScenarioException
89
from getgauge.messages.messages_pb2 import *
910
from getgauge.messages.spec_pb2 import Parameter, ProtoExecutionResult, Span
1011
from getgauge.parser import Parser
@@ -183,6 +184,8 @@ def test_Processor_execute_step_request(self):
183184
'', response.executionResult.errorMessage)
184185
self.assertEqual(
185186
'', response.executionResult.stackTrace)
187+
self.assertFalse(response.executionResult.skipScenario)
188+
self.assertEqual([], response.executionResult.message)
186189

187190
def test_Processor_execute_step_request_with_param(self):
188191
registry.add_step('Step <a> with <b>', impl, '')
@@ -204,6 +207,8 @@ def test_Processor_execute_step_request_with_param(self):
204207
'', response.executionResult.errorMessage)
205208
self.assertEqual(
206209
'', response.executionResult.stackTrace)
210+
self.assertFalse(response.executionResult.skipScenario)
211+
self.assertEqual([], response.executionResult.message)
207212

208213
def test_Processor_failed_execute_step_request(self):
209214
request = ExecuteStepRequest()
@@ -219,6 +224,8 @@ def test_Processor_failed_execute_step_request(self):
219224
self.assertNotEqual(
220225
'', response.executionResult.stackTrace)
221226
self.assertFalse(response.executionResult.recoverableError)
227+
self.assertFalse(response.executionResult.skipScenario)
228+
self.assertEqual([], response.executionResult.message)
222229

223230
def test_Processor_failed_execute_step_request_with_continue_on_failure(self):
224231
registry.add_step('Step 4', failing_impl, '')
@@ -236,6 +243,25 @@ def test_Processor_failed_execute_step_request_with_continue_on_failure(self):
236243
self.assertNotEqual('', response.executionResult.errorMessage)
237244
self.assertNotEqual('', response.executionResult.stackTrace)
238245
self.assertTrue(response.executionResult.recoverableError)
246+
self.assertFalse(response.executionResult.skipScenario)
247+
self.assertEqual([], response.executionResult.message)
248+
249+
def test_Processor_failed_execute_step_request_with_programmatic_skip(self):
250+
registry.add_step('Skipped Step', skipped_impl, '')
251+
252+
request = ExecuteStepRequest()
253+
request.parsedStepText = 'Skipped Step'
254+
255+
response = processor.process_execute_step_request(request)
256+
257+
self.assertIsInstance(response, ExecutionStatusResponse)
258+
self.assertFalse(response.executionResult.failed)
259+
self.assertEqual(
260+
'', response.executionResult.errorMessage)
261+
self.assertEqual(
262+
'', response.executionResult.stackTrace)
263+
self.assertTrue(response.executionResult.skipScenario)
264+
self.assertEqual(['Step programmatically skipped'], response.executionResult.message)
239265

240266
def test_Processor_starting_execution_request(self):
241267
registry.add_before_suite(impl1)
@@ -748,6 +774,9 @@ def impl2(context):
748774
def failing_impl():
749775
print([][1])
750776

777+
def skipped_impl():
778+
raise SkipScenarioException("Step programmatically skipped")
779+
751780

752781
if __name__ == '__main__':
753782
main()

0 commit comments

Comments
 (0)