-
Notifications
You must be signed in to change notification settings - Fork 5
Creating a high level test
Tom Longhurst edited this page Apr 27, 2020
·
1 revision
Tests can be constructed either by extending from a base class (recommended for cleaner and more readable tests), or by using the test builder object.
Extending from BDTestBase
public class MyTests : BDTestBase
{
[Test]
public void Test1() {
Given(() => Action1())
.When(() => Action2())
.Then(() => Action3())
.BDTest();
}
}
Or by using the BDTestBuilder
object
public class MyTests
{
[Test]
public void Test1() {
new BDTestBuilder().Given(() => Action1())
.When(() => Action2())
.Then(() => Action3())
.BDTest();
}
}
BDTest enforces best practice:
-
Tests MUST contain
-
Given
+When
+Then
and executed with aBDTest(Async)
- OR
-
When
+Then
and executed with aBDTest(Async)
The former would be when a test needs setup to get to the required state. The latter if no state is required.
-
-
Tests MUST start with a
Given
or aWhen
- Off of a
Given
you can haveAnd
orWhen
- Off of an
And
you can haveAnd
orWhen
- Off of an
- Off of a
When
you can have aThen
- (No
And
- We should be testing one action!)
- (No
- Off of a
Then
you can haveAnd
orBDTest(Async)
- Off of an
And
you can haveAnd
orBDTest(Async)
- Off of an
- Off of a