How to use finds_and_runs_three_class_level_examples method of NSpec.Tests.WhenRunningSpecs.SpecClass class

Best NSpec code snippet using NSpec.Tests.WhenRunningSpecs.SpecClass.finds_and_runs_three_class_level_examples

Run NSpec automation tests on LambdaTest cloud grid

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

describe_example.cs

Source: describe_example.cs Github

copy
1using System;
2using NUnit.Framework;
3using NSpec.Tests.WhenRunningSpecs.Exceptions;
4using FluentAssertions;
5
6namespace NSpec.Tests.WhenRunningSpecs
7{
8    [TestFixture]
9    [Category("RunningSpecs")]
10    public class describe_example : when_running_specs
11    {
12        class SpecClass : nspec
13        {
14            void it_changes_status_after_run()
15            {
16            }
17
18            void it_passes()
19            {
20            }
21
22            void it_fails()
23            {
24                throw new KnownException();
25            }
26        }
27
28        [Test]
29        public void execution_status_changes_after_run()
30        {
31            Run(typeof(SpecClass));
32
33            var ex = TheExample("it changes status after run");
34
35            //ex.HasRun.Should().BeFalse(); //broken after making init and run happen all at once
36
37            ex.HasRun.Should().BeTrue();
38        }
39
40        [Test]
41        public void duration_is_set_after_run()
42        {
43            Run(typeof(SpecClass));
44
45            var ex = TheExample("it changes status after run");
46
47            ex.Duration.Should().BeGreaterThan(TimeSpan.Zero);
48        }
49
50        [Test]
51        public void passing_status_is_passed_when_it_succeeds()
52        {
53            Run(typeof(SpecClass));
54
55            TheExample("it passes").ShouldHavePassed();
56        }
57
58        [Test]
59        public void passing_status_is_not_passed_when_it_fails()
60        {
61            Run(typeof(SpecClass));
62
63            TheExample("it fails").ShouldHaveFailed();
64        }
65
66        class SpecClassWithAnonymousLambdas : nspec
67        {
68            void describe_specs_with_anonymous_lambdas()
69            {
70                context["Some context with anonymous lambdas"] = () =>
71                {
72                    it["has an anonymous lambda"] = () =>
73                    {
74                    };
75                };
76            }
77        }
78
79        [Test]
80        public void finds_and_runs_three_class_level_examples()
81        {
82            Run(typeof(SpecClass));
83
84            TheExampleCount().Should().Be(3);
85        }
86
87        [Test]
88        public void finds_and_runs_only_one_example_ignoring_anonymous_lambdas()
89        {
90            Run(typeof(SpecClassWithAnonymousLambdas));
91
92            TheExampleCount().Should().Be(1);
93        }
94    }
95}
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

Most used method in SpecClass

Trigger finds_and_runs_three_class_level_examples code on LambdaTest Cloud Grid

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