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?
1 Answer
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:
-
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)? May 26, 2015 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. May 26, 2015 at 19:57