1
votes

My requirement is to test individually the dynamic list of URL's using specflow for success code 200

Current Approach: URL list is hard coded in the scenario outline like below wherein I am able to test each URL successfully. Here my test runs as many number of URL's present in the scenario outline and I can easily identify the failed tests if any.

 Scenario Outline: URL test
      Given list of URL's
      When I launch each URL 
      Then I should expect 200 HTTP status code

      Examples:
        | URL    |
        |  url 1 |  
        |  url 2 |  
        |  url..n| 

New Approach: I am thinking to get the list of URL from the web service dynamically instead of hard coding in the scenario outline.

Scenario Outline: URL test
          Given a service to get list of URL's
          When I call the API get
          Then I should expect 200 HTTP status code

With the above approach am able to get the list of URL's and by iterating am able to launch them individually. The problem here is since there is no scenario outline, In a single test, complete list of URL's will be executed.

I need a way wherein I can create a dynamic data set and each URL testing will happen in its own test method, rather executing list of URL's in a single test method.

Tools Used: C# , NUnit , Specflow , Resharper, Visual Studio

Am using ReSharper to execute my tests and I looked about dynamic Table / Instance concepts .

2
Why are you implementing this as a SpecFlow scenario? Use a simple unit test for it.Andreas Willich
We are have automated testing framework with specflow, so leveraging the same!user1617707

2 Answers

2
votes

Since I cannot (yet) add comments I will supply my comment as an answer.

You probably shouldn't use a scenario in this situation. Scenarios are meant to describe the behavior of the system from a business perspective (in other words business value).

Here it seems that you want to make sure a list of uri's is responding fine. This sounds more as an internal integration test than an actual business verification.

I suggest putting this in a single integration test. There you can simply create a collection of failing uri's. At the end of the test you can simply assert whether the collection contains 0 elements.

1
votes

You can't dynamically generate table data during tests execution because .cs files are already compiled.

Write parameterized unit tests instead.

Or of course, you can write a tool which will parse your urls, rewrite .feature file, rebuild SpecFlow solution and run tests. JFF :)