The web application I am working on is currently (partially) tested automatically. All scenarios are hardcoded in custom code in this way :
WebElement bt = findButtonWithLabel("foo")
bt.click();
WebElement input = ...
input.sendKeys("...");
// ... do that
// ... verify the text "baz" is present on the page
I want to switch to BDD scenarios with all the benefits that come with it.
First I want to move for this imperative way and write business sentences.
So far so good. On small scenarios, it's relatively easy, after discussing with product owner, we found the business words to use. So bye-bye the click there
, do that
!
Given a manager connected to the application
And an operation is waiting for approbation
When the manager refuse the operation
Then the operation status changes to refused
Ok good!
But the real use-case is to test a large workflow (a big Camunda BPMN) with lot of states, lot of user interactions, etc.
And I don't know how to write such scenarios.
It seems not a good BDD scenario to write something like that:
Given an operation newly created
And document "pdf1" is added
And document "pdf2" is added
When employee1 do that
Then operation status is that
When employee2 do that
...
(a lot of steps)
...
Then operation status is waiting for approbation
When the manager accept the operation
Then the operation status changes to accepted
But testing small part of the workflow is difficult as I can't easily create an operation at a specific state. It requires a lot of data, and I can insert data directly in the database to put create the operation at a given state just for the test.
How should I do?
What is the best practices in such a case?