Run the SpecFlow Infinity Test

I have a SpecFlow test that fails if you run it enough time. How can I take an existing SpecFlow test and make it work endlessly until it works? (Ideally, I would like to calculate how many times it will take.)

My initial guess was to just call the binding methods, which the script test ultimately calls, but I keep getting null pointer exceptions. SpecFlow seems to initialize what I don't know.

My next assumption was to try to run the automatically generated code for the test function, but it seems like it needs all kinds of data from the SpecFlow framework, which I don’t know how to generate.

All I want to do is run the test several times. Is there really got to be some way to accomplish this completely trivial task?

+4
source share
1 answer

I think I tried too hard. Here is what I came up with:

using System; using NUnit.Framework; [TestFixture] public sealed class StressTest { [Test] public void Test() { var thing = new FoobarFeature(); thing.FeatureSetup(); thing.TestInitialize(); var n = 0; while (true) { Console.WriteLine("------------ Attempt {0} ----------------", n); thing.Scenario1(); thing.Scenario2(); thing.Scenario3(); n++; } } } 

I have a Foobar.feature file that automatically generates a Foobar.feature.cs file containing the FoobarFeature class. The names of the scripts obviously change depending on what is in your properties file.

I am not 100% sure that this works for tests having a complicated setup / shutdown, but it works for my specific case ...

+2
source

All Articles