1

I have the following rspec test code below which basically makes an API call to a server and gets all_elem_ids from get_all_queries. I'm trying to have tests run in parallel such that the 'it' block gets executed for each of the values for all_elem_ids variable, with perhaps like a max thread count of 5. Unfortunately with the code below it seems to be creating threads but the actual code ends up doing nothing. The it block gets executed 5 times but however I can see that the tests don't actually execute but are still declared as "Passed"

Code:

ids = ['2']

RSpec.describe 'Verify data' do
  unless ids.nil?
    ids.each do |val_a|
      context "Elem id: #{val_a}" do
        all_elem_ids = get_all_queries(val_a)
        # example value, all_elem_ids= ['1', '56', '9', '10']

        all_elem_ids.each do |val_b|
          it "Verify data for id: #{val_b}" do
            Thread.new{
            run_test_a(val_b.to_s)
            run_test_b(val_b.to_s)
            }
          end
        end
      end
    end
  end
end
soni
  • 19
  • 3
  • 1
    See https://stackoverflow.com/a/18726293/2981429 you need to wait for all the threads to finish – max pleaner Dec 03 '19 at 05:52
  • Rspec doesn't support the parallel execution. I have raised a related question here https://stackoverflow.com/questions/56083800/how-to-run-parrellel-tests-with-rspec-and-watir-on-a-windows-machine – Rajagopalan Dec 03 '19 at 10:47
  • This is not execution. You're **defining** specs in parallel, not executing them. See more info here https://stackoverflow.com/a/59162511/299774 – Greg Dec 03 '19 at 17:35

0 Answers0