0

I started writing unit tests recently and need to test reading fields in a spreadsheet (.xlsx and .xls), my biggest question is:
Should I create a spreadsheet by code using Apache POI or use external spreadsheet models that are used in software? What is the best practice?

0

How the spreadsheet/workbook is created shouldn't matter. You may have some issues with cells whose value is derived from a formula though. I like to work with .csv files if at all possible. They are much easier to parse if you write the java code yourself (without using 3rd party libraries).

Here are a few examples for Excel file types, from HelloSelenium.com, that I found:

  1. HOW TO PERFORM DATA DRIVEN USING EXCEL FILE (.XLSX) IN SELENIUM WEBDRIVER ?
  2. HOW TO READ DATA FROM EXCEL FILE (.XLSX) USING APACHE POI?
| improve this answer | |
  • My question is time to take the test. The code that will test already uses Apache POI. When testing, ride a Java spreadsheet or make test with an existing spreadsheet (External file)? – Daniela Morais May 26 '15 at 19:47
  • I would call the file if it is static. In some of my tests that require a file for a FileDialog, I first check to see if the file exists on the file system and if not I generate a new one or copy it to the local file system from some other end-point. – kirbycope May 26 '15 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.