I am running automated BDD steps using NUnit
assertions for each step ie Then
And
for my UI tests.
The NUnit
assertions are confined to confined to each method. This means that if an assertion in a method fails, then the other steps won't be run.
I was thinking of using NUnit Multiple Assert
but this requires all the asserts to be together. Any ideas?
BDD Steps
Then I am shown results for("foo")
And the page count is(3)
I am using the LightBDD
Library https://github.com/LightBDD/LightBDD
// Then Step
private void ThenIAmShownResultsFor(string expectedResults)
{
Assert.AreEqual(expectedResults, actual);
}
// And Step
private void AndThePageCountIs(int expectedResults)
{
Assert.AreEqual(expectedResults, actual);
}
See this article . Your tests that are reliant on the result of another should mock those other tests or methods. Each test should be completely decoupled from any other tests. You should never, ever, ever make one test dependent on the results of another. If a test relies on the results of another, you need to mock the response from the other test.
The code, assuming _foo
// And Step
private void AndThePageCountIs(int expectedResults)
{
actual = _foo.Setup(x => x.ThenIAmShownResultsFor()).Returns(expectedResults);
Assert.AreEqual(expectedResults, actual);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.