0

I've written single test scenario that runs on multiple websites (around 400) and return the actual status code of the website. (Expected to be 200 when the site is up and running).

I'm using Scenario Outline and Examples to write down the test data and I'm using capybara-webkit to check the expected http status code.

However, is there any alternate way of testing this functionality as currently my feature file is very bulky.

Poo M
  • 31
  • 3

3 Answers3

0

Best bet is just using a script and something like bash and a curl handle.

It would be literally 1/2 lines of code for your testing, and then just your original loop

Cucumber is designed to be your documentation, your specification and your tests all in the same place. Unless you own all of those websites, then it's better to have something a bit less bulky.

Luke

Luke Hill
  • 460
  • 2
  • 10
0

What about using a service like this: https://httpstatus.io/ it checks the http status big multiple sites and offers an api to integrate it with your app

  • Thanks Daniel. It looks good to me. However, is it possible to make use of the above url in cucumber to verify the tests? I want to run these tests periodically as part of my regression testing. – Poo M Oct 29 '20 at 12:13
  • Sure you can use it, the site gives you an api key, besides the status api is open to public, and on the cucumber side you can use it with HttpPost – DanielValenzuela Nov 17 '20 at 17:04
0

You can write a much simpler cuke by giving the set of websites a name and pushing the details of the set down in the step definitions (ideally via a helper method). This allows you to remove your set of URL's from the feature and put them somewhere else.

Scenario: Check foo websites
  Given foo websites
  When I check the foo websites
  Then I should see no errors

and then implement the When something like (below is pseudocode in ruby style)

When 'I check the foo websites' do
  sites = load_foo_websites
  @errors = {}
  sites.each do |site|
    @errors << (site_ok(site) is false)
  end
end

Now you have stored your @errors in a global that you can access in your Then.

The load_foo_websites method can get your websites from anywhere, as it is code.

diabolist
  • 3,990
  • 1
  • 11
  • 15