How to use setup method of NSpec.Tests.WhenRunningSpecs.BeforeAndAfter.DerivedSpec class

Best NSpec code snippet using NSpec.Tests.WhenRunningSpecs.BeforeAndAfter.DerivedSpec.setup

Run NSpec automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

inheritance.cs

Source: inheritance.cs Github

copy
1using FluentAssertions;
2using NUnit.Framework;
3
4namespace NSpec.Tests.WhenRunningSpecs.BeforeAndAfter
5{
6    [TestFixture]
7    public class inheritance : when_running_specs
8    {
9        class BaseSpec : sequence_spec
10        {
11            void before_all()
12            {
13                sequence = "A";
14            }
15
16            void before_each()
17            {
18                sequence += "C";
19            }
20
21            void after_each()
22            {
23                sequence += "F";
24            }
25
26            void after_all()
27            {
28                sequence += "H";
29            }
30        }
31
32        class DerivedSpec : BaseSpec
33        {
34            void a_context()
35            {
36                beforeAll = () => sequence += "B";
37
38                before = () => sequence += "D";
39                specify = () => Assert.That(true, Is.True);
40                after = () => sequence += "E";
41
42                afterAll = () => sequence += "G";
43            }
44        }
45
46        [SetUp]
47        public void setup()
48        {
49            Run(typeof(DerivedSpec));
50        }
51
52        [Test]
53        public void before_alls_at_every_level_run_before_before_eaches_from_the_outside_in()
54        {
55            DerivedSpec.sequence.Should().StartWith("ABCD");
56        }
57
58        [Test]
59        public void after_alls_at_every_level_run_after_after_eaches_from_the_inside_out()
60        {
61            DerivedSpec.sequence.Should().EndWith("EFGH");
62        }
63    }
64}
Full Screen

Accelerate Your Automation Test Cycles With LambdaTest

Leverage LambdaTest’s cloud-based platform to execute your automation tests in parallel and trim down your test execution time significantly. Your first 100 automation testing minutes are on us.

Try LambdaTest

Trigger setup code on LambdaTest Cloud Grid

Execute automation tests with setup on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free
LambdaTestX

We use cookies to give you the best experience. Cookies help to provide a more personalized experience and relevant advertising for you, and web analytics for us. Learn More in our Cookies policy, Privacy & Terms of service

Allow Cookie
Sarah

I hope you find the best code examples for your project.

If you want to accelerate automated browser testing, try LambdaTest. Your first 100 automation testing minutes are FREE.

Sarah Elson (Product & Growth Lead)