Forum Discussion

davidcole's avatar
davidcole
Occasional Contributor
12 years ago

Datasource based tests - only perform query first time

Is there a way of performing a query and then sequentially going through those results rather than requerying each time?

I have a profiler step which calls one of 5 test cases depending on a random number.

But each test step includes a SQL query for data to use in the test. I suspect that each time the test case is being called that the query is being run.

Is there a way of getting the query to be run only once and then using all the results for each successive run of the test case?

2 Replies

  • I don't believe there's a configuration for that.

    Are you trying to setup result caching because the query takes too long? Typically there's caching on the DBMS level where following same query returns the results pretty quickly.

    Regards,
    Michael Giller
    SmartBear Software
  • davidcole's avatar
    davidcole
    Occasional Contributor
    yeah essentially.

    We have two web methods, a search and a retrieval - and they are called with different parameters depending on the type of document you want to return - a statement or a credit card statement.

    The first step of my test case choose a random number between 1 and 100 - 60 and below will call the Search Statements Test Case, 60 to 40 will call the Search Credit Cards test case.

    Then the search Statements (and credit cards test cases) is to select 100 records from the relevant table in the DB, then perform a search, then as there is one expected result with is retrieved.

    With this config, I can't use the dataloop at the end of the search statement and it just stays in that test case. So I was hoping that it would pass through the statement test case, then next time the statements test case would be used that the dataset would be reused...


    I think, I may have to set something else up which depending on the environment, read from the database to a known CSV file....then use the CSV file as part of the test cases. Then I'd only have to change CSV file on change on environment.