Custom execution order for tests in rspec

12 views
Skip to first unread message

Aravindh Sridharan

unread,
Jul 20, 2016, 8:05:59 AM7/20/16
to rspec
Hi, I am currently having a issue with respect to execution order of tests in our rspec suite. Our application is big data pipeline where the front facing server (collector) accepts requests and sends the data to other components for transformation. So the collector responds with 202 status rather than 200. After few seconds the data is available for querying. The Querying server (QueryAPI) responds to certain queries on the data. In order to test this, I have to put data into collector, wait for sometime and query the QueryAPI and assert the result. I didnt want to repeat this process for every test as sleeping for every test is time consuming. So currently the tests are like put all the data required to the collector in before block and at the end of before block, wait for sometime and then the "it" block will call QueryAPI and assert. This seems ugly as it is difficult for me to map the test data with the test. Is there a way to create two custom blocks viz. ingest" bock & "query" block inside "it" block and then run all ingest blocks together, wait for sometime and run query blocks. This will help in readability of the tests. Below is an example of what i want



describe "Test" do
  it "Test 1" do
    ingest "collector" do
      #input data here
    end
    query "queryapi" do
      assert result here
    end
  end
  it "Test 2" do
    ingest "collector" do
      #input data here
    end
    query "queryapi" do
      assert result here
    end
  end
end

The ingest blocks of two tests should run first, wait for sometime and then run the query blocks. Is this possible?

Myron Marston

unread,
Jul 20, 2016, 9:37:46 AM7/20/16
to rs...@googlegroups.com
We don't support the ability to pause a spec and allow another one to proceed, then later resume the spec.  It goes against some of the main principles that guided the design of RSpec such as test independence and isolation.

Sorry :(.

Myron

--
You received this message because you are subscribed to the Google Groups "rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rspec+un...@googlegroups.com.
To post to this group, send email to rs...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rspec/e9891215-7c49-4b73-9de4-24979e3058f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages