简体   繁体   中英

Importing a large amount of data for testing only.

Here is some background:

I have a client that wants me to test a rails app against a large number of potential inputs in a form page. He has an Excel spreadsheet with about 200 potential input combinations that will be entered into the form.

The client want's the app to be able to "read" the spreadsheet and execute the couple hundred form submissions.

My solution was to just import the spreadsheet into a database table, but the client doesn't want an extra database table in the application.

So here is the question:

Is it possible/not exceptionally complicated to read/crawl a spreadsheet or csv file to do the above, or import data into only the test database?

I haven't been able to find any resources that aren't about simply importing the spreadsheet.

Thanks!

Use spreadsheet gem to read and parse your data from excel.

Use capybara to automate the form submission. Initial learning curve will be steep, but once you get a hang of it, it comes really handy to automate web interactions.

There is a ruby gem called roo which allows you to access the contents of:

  1. Open-office spreadsheets (.ods)
  2. Excel spreadsheets (.xls)
  3. Google (online) spreadsheets
  4. Excel's new file format .xlsx

Using this gem, you can read test data from file and use them in tests to execute.

Do you have some magical method for importing the spreadsheet into the database already? Because the way I see it, you're going to have to parse the spreadsheet at some point anyway and there's no good reason to add overhead by throwing all of this into a database. Write a script that takes the entries and tries them, submission by submission, that way you won't need to store anything.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM