How to use execution_should_run_in_the_correct_order method of NSpec.Tests.WhenRunningSpecs.Class5 class

Best NSpec code snippet using NSpec.Tests.WhenRunningSpecs.Class5.execution_should_run_in_the_correct_order

Run NSpec automation tests on LambdaTest cloud grid

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

describe_abstract_class_execution_order.cs

Source: describe_abstract_class_execution_order.cs Github

copy
1using System;
2using NSpec;
3using NSpecSpecs.WhenRunningSpecs;
4using NUnit.Framework;
5
6namespace NSpecSpecs.describe_RunningSpecs
7{
8    [TestFixture]
9    public class describe_abstract_class_execution_order : when_running_specs
10    {
11        abstract class Class1 : nspec
12        {
13            public string beforeExecutionOrder = "", actExecutionOrder = "", afterExecutionOrder = "", allExecutions = "";
14
15            public void LogBefore(string classId)
16            {
17                beforeExecutionOrder += classId;
18                allExecutions += "b" + classId;
19            }
20
21            public void LogAct(string classId)
22            {
23                actExecutionOrder += classId;
24                allExecutions += "ac" + classId;
25            }
26
27            public void LogAfter(string classId)
28            {
29                afterExecutionOrder += classId;
30                allExecutions += "af" + classId;
31            }
32
33            public void LogExample(string classId)
34            {
35                allExecutions += "i" + classId;
36            }
37
38            void abstract1_example()
39            {
40                it["abstract1 tests nothing", "example_in_abtract_class"] = () => LogExample(classId: "1");
41            }
42
43            void before_each()
44            {
45                LogBefore(classId: "1");
46            }
47
48            void act_each()
49            {
50                LogAct(classId: "1");
51            }
52
53            void after_each()
54            {
55                LogAfter(classId: "1");
56            }
57        }
58
59        class Class2 : Class1
60        {
61            void concrete2_example()
62            {
63                it["concrete2 tests nothing", "example_in_concrete_class_that_inherits_abstract"] = () => LogExample(classId: "2");
64            }
65
66            void before_each()
67            {
68                LogBefore(classId: "2");
69            }
70
71            void act_each()
72            {
73                LogAct(classId: "2");
74            }
75
76            void after_each()
77            {
78                LogAfter(classId: "2");
79            }
80        }
81
82        abstract class Class3 : Class2
83        {
84            void abstract3_example()
85            {
86                it["abstract3 tests nothing", "example_in_abstract_class_that_directly_inherits_from_concrete_class"] = () => LogExample(classId: "3");
87            }
88
89            void before_each()
90            {
91                LogBefore(classId: "3");
92            }
93
94            void act_each()
95            {
96                LogAct(classId: "3");
97            }
98
99            void after_each()
100            {
101                LogAfter(classId: "3");
102            }
103        }
104
105        abstract class Class4 : Class3
106        {
107            void abstract4_example()
108            {
109                it["abstract4 tests nothing", "example_in_abstract_class_that_inherits_another_abstract_class"] = () => LogExample(classId: "4");
110            }
111
112            void before_each()
113            {
114                LogBefore(classId: "4");
115            }
116
117            void act_each()
118            {
119                LogAct(classId: "4");
120            }
121
122            void after_each()
123            {
124                LogAfter(classId: "4");
125            }
126        }
127
128        class Class5 : Class4
129        {
130            void concrete5_example()
131            {
132                it["concrete5 tests nothing", "example_in_concrete_class_that_inherits_an_abstract_class_with_deep_inheritance_chain"] = () => LogExample(classId: "5");
133            }
134
135            void before_each()
136            {
137                LogBefore(classId: "5");
138            }
139
140            void act_each()
141            {
142                LogAct(classId: "5");
143            }
144
145            void after_each()
146            {
147                LogAfter(classId: "5");
148            }
149        }
150
151        [Test(Description = "before_each() in concrete classes affects base abstracts"),
152         TestCase(typeof(Class2), "example_in_abtract_class", "12"),
153         TestCase(typeof(Class2), "example_in_concrete_class_that_inherits_abstract", "12"),
154         TestCase(typeof(Class5), "example_in_abstract_class_that_directly_inherits_from_concrete_class", "12345"),
155         TestCase(typeof(Class5), "example_in_abstract_class_that_inherits_another_abstract_class", "12345"),
156         TestCase(typeof(Class5), "example_in_concrete_class_that_inherits_an_abstract_class_with_deep_inheritance_chain", "12345")]
157        public void before_eaches_should_run_in_the_correct_order(Type withRespectToContext, string tags, string beforeExecutionLog)
158        {
159            this.tags = tags;
160            Run(withRespectToContext);
161
162            var specInstance = classContext.GetInstance() as Class1;
163
164            specInstance.beforeExecutionOrder.should_be(beforeExecutionLog);
165        }
166
167        [Test(Description = "act_each() in concrete classes affects base abstracts"),
168         TestCase(typeof(Class2), "example_in_abtract_class", "12"),
169         TestCase(typeof(Class2), "example_in_concrete_class_that_inherits_abstract", "12"),
170         TestCase(typeof(Class5), "example_in_abstract_class_that_directly_inherits_from_concrete_class", "12345"),
171         TestCase(typeof(Class5), "example_in_abstract_class_that_inherits_another_abstract_class", "12345"),
172         TestCase(typeof(Class5), "example_in_concrete_class_that_inherits_an_abstract_class_with_deep_inheritance_chain", "12345")]
173        public void act_eaches_should_run_in_the_correct_order(Type withRespectToContext, string tags, string actExecutionLog)
174        {
175            this.tags = tags;
176            Run(withRespectToContext);
177
178            var specInstance = classContext.GetInstance() as Class1;
179
180            specInstance.actExecutionOrder.should_be(actExecutionLog);
181        }
182
183        [Test(Description = "after_each() in concrete classes affects base abstracts"),
184         TestCase(typeof(Class2), "example_in_abtract_class", "21"),
185         TestCase(typeof(Class2), "example_in_concrete_class_that_inherits_abstract", "21"),
186         TestCase(typeof(Class5), "example_in_abstract_class_that_directly_inherits_from_concrete_class", "54321"),
187         TestCase(typeof(Class5), "example_in_abstract_class_that_inherits_another_abstract_class", "54321"),
188         TestCase(typeof(Class5), "example_in_concrete_class_that_inherits_an_abstract_class_with_deep_inheritance_chain", "54321")]
189        public void after_eaches_should_run_in_the_correct_order(Type withRespectToContext, string tags, string afterExecutionLog)
190        {
191            this.tags = tags;
192            Run(withRespectToContext);
193
194            var specInstance = classContext.GetInstance() as Class1;
195
196            specInstance.afterExecutionOrder.should_be(afterExecutionLog);
197        }
198
199        [Test,
200         TestCase(typeof(Class2), "example_in_abtract_class", "b1b2ac1ac2i1af2af1"),
201         TestCase(typeof(Class2), "example_in_concrete_class_that_inherits_abstract", "b1b2ac1ac2i2af2af1"),
202         TestCase(typeof(Class5), "example_in_abstract_class_that_directly_inherits_from_concrete_class", "b1b2b3b4b5ac1ac2ac3ac4ac5i3af5af4af3af2af1"),
203         TestCase(typeof(Class5), "example_in_abstract_class_that_inherits_another_abstract_class", "b1b2b3b4b5ac1ac2ac3ac4ac5i4af5af4af3af2af1"),
204         TestCase(typeof(Class5), "example_in_concrete_class_that_inherits_an_abstract_class_with_deep_inheritance_chain", "b1b2b3b4b5ac1ac2ac3ac4ac5i5af5af4af3af2af1")]
205        public void execution_should_run_in_the_correct_order(Type withRespectToContext, string tags, string fullExecutionLog)
206        {
207            this.tags = tags;
208            Run(withRespectToContext);
209
210            var specInstance = classContext.GetInstance() as Class1;
211
212            specInstance.allExecutions.should_be(fullExecutionLog);
213        }
214    }
215}
216
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 execution_should_run_in_the_correct_order code on LambdaTest Cloud Grid

Execute automation tests with execution_should_run_in_the_correct_order 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)