Suppose I have a program that does three things in succession:
Task 1Task 2Task 3
Now suppose I want to write BDDs for Task 2. Let us say when it fails. Now Task 2 is performed only after Task 1 succeeds. But Task 1 itself can succeed in many ways (for instance, we my program retries Task 1 if the downstream system responds with an error for a fixed number of times). My question is, what all behaviour of Task 1 should I consider when writing tests for Task 2?
Given_Task2Fails_Task1IsRetried_Expect_SomeBehaviour Given_Task2Fails_Task1IsNotRetried_Expect_SomeBehaviour If this is the case, then I need create all the permutations and combinations of each of the tasks keeping Task 2 as constant. This blows up the number of scenarios with a large amount of duplicate code. This is what I mean:
Given_Task2Fails_Task1IsRetried_Task3IsNotRetried_Expect_SomeBehaviour Given_Task2Fails_Task1IsNotRetried_Task3IsNotRetried_Expect_SomeBehaviour Given_Task2Fails_Task1IsRetried_Task3IsRetried_Expect_SomeBehaviour Given_Task2Fails_Task1IsNotRetried_Task3IsRetried_Expect_SomeBehaviour How do I write solid scenarios in such cases? Ideally, I would want to vary each and every parameter of my system keeping Task 2 constant. But that's like a brute-force approach and I am pretty sure there are better approaches out there.