How would I structure this SpecFlow Feature/Scenario set correctly?
Tag : chash , By : Denis Chaykovskiy
Date : March 29 2020, 07:55 AM
will be helpful for those in need You have different contexts in these scenarios. When same event occurs in different contexts you have different outcomes. Thats what you are describing by these scenarios. So, there is no problem with repeating When step. You actually do same thing twice. Just reuse it. If in some scenarios you will have same contexts, but different events, then you will have repeating Given steps. Same with outcomes. Scenario: Gutter game
Given a new bowling game
When all balls landing in gutter
Then total score should be 0
Scenario: All strikes
Given a new bowling game
When all rolls are strikes
Then total score should be 300
[Given(@"a new bowling game")]
public void GivenANewBowlingGame()
{
_game = new Game();
}
[Then(@"my total score should be (\d+)")]
public void ThenMyTotalScoreShouldBe(int score)
{
Assert.AreEqual(score, _game.Score);
}
|
SpecFlow stop feature in case a scenario fails
Tag : chash , By : kameel
Date : March 29 2020, 07:55 AM
this one helps. Using Feature Context, you could probably have each sentence start with something like this... Given Previous tests did not fail
bool testsPass = FeatureContext.Current["TestsPass"];
Assert.IsTrue(testsPass);
bool testPassed = //something to test
FeatureContext.Current["testsPass"] = testPassed;
Assert.IsTrue(testPassed);
|
Tag : vb.net , By : Si Gardner
Date : March 29 2020, 07:55 AM
|
C# Specflow - Need Feature and Scenario Title without using FeatureContext and ScenarioContext
Tag : chash , By : silvervino
Date : March 29 2020, 07:55 AM
I wish this help you Yes, you can get the current FeatureContext and ScenarioContext by getting it via constructor injection. public class MyBindingClass
{
private ScenarioContext scenarioContext;
public MyBindingClass(ScenarioContext scenarioContext)
{
this.scenarioContext = scenarioContext;
}
[When("I say hello to ScenarioContext")]
public void WhenISayHello()
{
// access scenarioContext here
}
}
|
In the latest release SpecFlow menu items "Run SpecFlow Scenario" and "Debug SpecFlow Scenario" are
Date : March 29 2020, 07:55 AM
wish of those help When compiling scripts, SpecFlow generates unit tests. You need to debug them. The breakpoints on the script file will work.
|