Igal
Igal

Reputation: 4783

What is the best practices to fail Jbehave story

I'm new to BDD and Jbehave , so sorry if the question is too stupid.

I know that the assertion should be in Given state. but this state verify correctness of the functionality.

How can I stop / fail the story even before it reaches Given state.

let's say , the scenario i want to validate is login with different accounts. and in Given I'm validating that I have username textbox (it's enable / editable / etc ...)

From one hand , username textbox is required for successful log in , but other hand , it's not the tested functionality ...

Is there any way just to stop the test in case and there is no textbox exists ?

Upvotes: 0

Views: 405

Answers (1)

Seb Rose
Seb Rose

Reputation: 3666

JBehave (and Cucumber) uses the Gherkin Given/When/Then syntax, which mirrors the common Arrange/Act/Assert idiom.

Given - setup the context for the scenario When - perform some action Then - assert that the expected outcome has occurred

However, the implementation you write for any step (the 'glue' code) can do anything you want it to. If an exception is thrown (and not caught), then the scenario will fail, irrespective of what type of step it is. So, you could write code to check for an editable username textbox in your 'Given' step. I don't recommend that you do this, but nothing in JBehave will stop you.

Upvotes: 2

Related Questions