{"id":22360364,"url":"https://github.com/sergueik/testng-dataproviders","last_synced_at":"2025-07-30T13:31:49.169Z","repository":{"id":41975740,"uuid":"97987031","full_name":"sergueik/testng-dataproviders","owner":"sergueik","description":"This project exercises TestNG data providers: Excel 2003, 2007,  Open Office, JSON, csv, Fillo","archived":false,"fork":false,"pushed_at":"2024-10-03T18:42:52.000Z","size":388,"stargazers_count":16,"open_issues_count":2,"forks_count":12,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-06T09:03:01.322Z","etag":null,"topics":["poi","selenium","testng"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sergueik.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2017-07-21T21:14:30.000Z","updated_at":"2025-02-13T07:28:05.000Z","dependencies_parsed_at":"2023-02-18T02:20:31.882Z","dependency_job_id":"c0a4a316-f526-4587-bc96-58b53287385f","html_url":"https://github.com/sergueik/testng-dataproviders","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sergueik/testng-dataproviders","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergueik%2Ftestng-dataproviders","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergueik%2Ftestng-dataproviders/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergueik%2Ftestng-dataproviders/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergueik%2Ftestng-dataproviders/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sergueik","download_url":"https://codeload.github.com/sergueik/testng-dataproviders/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sergueik%2Ftestng-dataproviders/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267875488,"owners_count":24158780,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["poi","selenium","testng"],"created_at":"2024-12-04T16:15:59.245Z","updated_at":"2025-07-30T13:31:48.833Z","avatar_url":"https://github.com/sergueik.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"###  TestNg-DataProviders [![BuildStatus](https://travis-ci.org/sergueik/testng-dataproviders.svg?branch=master)](https://travis-ci.org/sergueik/testng-dataproviders.svg?branch=maste://travis-ci.org/sergueik/testng-dataproviders.svg?branch=master)\r\n\r\nThis project exercises [testng dataProviders](http://testng.org/doc/documentation-main.html#parameters-dataproviders)\r\nbacked by various Office formats\r\n\r\n  * Excel 2003 OLE documents - Horrible SpreadSheet Format [org.apache.poi.hssf.usermodel.*)](http://shanmugavelc.blogspot.com/2011/08/apache-poi-read-excel-for-use-of.html)\r\n  * Excel 2007 OOXML (.xlsx) - XML SpreadSheet Format [org.apache.poi.xssf.usermodel.*](http://howtodoinjava.com/2013/06/19/readingwriting-excel-files-in-java-poi-tutorial/)\r\n  * OpenOffice SpreadSheet (.ods) [example1](http://www.programcreek.com/java-api-examples/index.php?api=org.jopendocument.dom.spreadsheet.Sheet), [example 2](http://half-wit4u.blogspot.com/2011/05/read-openoffice-spreadsheet-ods.html)\r\n  * Custom JSON [org.json.JSON](http://www.docjar.com/docs/api/org/json/JSONObject.html)\r\n  * csv [testng csv file](http://stackoverflow.com/questions/26033985/how-to-pass-parameter-to-data-provider-in-testng-from-csv-file)\r\n  * fillo [fillo](http://codoid.com/fillo/)\r\n  * [Google sheet](https://www.google.com/sheets/about/) (experimental).\r\n\r\nUnlike core TestNg data providers configurable through annotation constant parameters this Data provider class features runtime-flexible data file paths iparameterization enabling one running the jar with environment-specific test data without recompiling the java project. This feature was requested in one of the forums and was easy to implement - details in in __Extra Features__ section below.\r\n\r\n### Testing\r\n\r\nFor example test case performs Selenium link count test with the data providers of the following supported data types:\r\n\r\n* Excel 2003\r\n* Excel 2007\r\n* Open Office Spreadsheet\r\n* JSON\r\n\r\nThe test inputs are defined as spreadsheet with columns\r\n\r\n| ROWNUM |  SEARCH | COUNT |\r\n|--------|---------|-------|\r\n| 1      | junit   | 100   |\r\n\r\nor a JSON file with the following structure:\r\n```javascript\r\n{\r\n    \"test\": [{\r\n        \"keyword\": \"junit\",\r\n        \"count\": 101.0,\r\n        \"comment\": \"\",\r\n        \"other unused column\": \"\",\r\n    }, {\r\n        \"comment\": \"\",\r\n        \"keyword\": \"testng\",\r\n        \"count\": 31.0\r\n    },\r\n...\r\n]\r\n}\r\n```\r\n\r\nwhich represent the test `id`, the *seach term* and *expected minimum count* of articles found on the forum through title search.\r\n\r\nThe following annotations are provided to the test methods:\r\n\r\n```java\r\n@Test(enabled = true, singleThreaded = false, threadPoolSize = 1, invocationCount = 1, description = \"searches publications for a keyword\", dataProvider = \"Excel 2003\")\r\n@DataFileParameters(name = \"data_2003.xls\", path = \"${USERPROFILE}\\\\Desktop\", sheetName = \"Employee Data\")\r\n\tpublic void test_with_Excel_2003(double rowNum, String search_keyword,\r\n\t\t\tdouble expected_count) throws InterruptedException {\r\n\t\tparseSearchResult(search_keyword, expected_count);\r\n\t}\r\n```\r\nor\r\n```java\r\n@Test(enabled = true, singleThreaded = false, threadPoolSize = 1, invocationCount = 1, description = \"searches publications for a keyword\", dataProvider = \"Excel 2007\")\r\n@DataFileParameters(name = \"data_2007.xlsx\", path = \".\")\r\n\tpublic void test_with_Excel_2007(double rowNum, String search_keyword,\r\n\t\t\tdouble expected_count) throws InterruptedException {\r\n\t\tparseSearchResult(search_keyword, expected_count);\r\n\t}\r\n```\r\nor\r\n```java\r\n@Test(enabled = true, singleThreaded = false, threadPoolSize = 1, invocationCount = 1, description = \"searches publications for a keyword\", dataProvider = \"OpenOffice Spreadsheet\")\r\n@DataFileParameters(name = \"data.ods\", path = \"src/main/resources\") // when datafile path is relative assume it is under ${user.dir}\r\n\tpublic void test_with_OpenOffice_Spreadsheet(double rowNum,\r\n\t\t\tString search_keyword, double expected_count)\r\n\t\t\tthrows InterruptedException {\r\n\t\tparseSearchResult(search_keyword, expected_count);\r\n\t}\r\n```\r\nor\r\n```java\r\n@Test(enabled = true, singleThreaded = false, threadPoolSize = 1, invocationCount = 1, description = \"searches publications for a keyword\", dataProvider = \"JSON\")\r\n@JSONDataFileParameters(name = \"data.json\", dataKey = \"test\", columns = \"keyword,count\"\r\n  // one need to list value columns explicitly with JSON due to the way org.json.JSONObject is implemented\r\n\tpublic void test_with_JSON(String search_keyword, double expected_count)\r\n\t\t\tthrows InterruptedException {\r\n\t\tparseSearchResult(search_keyword, expected_count);\r\n\t}\r\n```\r\nThe data provider class will load all columns from Excel 2003, Excel 2007 or OpenOffice spreadsheet respectively and columns defined for JSON data provider\r\nand run test method with every row of data. It is up to the test developer to make the test method consume the correct number and type or parameters as the columns\r\nin the spreadsheet.\r\n\r\nTo enable debug messages during the data loading, set the `debug` flag with `@DataFileParameters` attribute:\r\n```java\r\n\t@Test(enabled = true, singleThreaded = true, threadPoolSize = 1, invocationCount = 1, description = \"# of articless for specific keyword\", dataProvider = \"Excel 2007\", dataProviderClass = ExcelParametersProvider.class)\r\n\t@DataFileParameters(name = \"data_2007.xlsx\", path = \".\", sheetName = \"Employee Data\", debug = true)\r\n\tpublic void test_with_Excel_2007(double rowNum, String searchKeyword,\r\n\t\t\tdouble expectedCount) throws InterruptedException {\r\n\t\tdataTest(searchKeyword, expectedCount);\r\n\t}\r\n```\r\n\r\nthis will show the following:\r\n```shell\r\nData Provider Caller Suite: Suite 1\r\nData Provider Caller Test: Parse Search Result\r\nData Provider Caller Method: test_with_Excel_2007\r\n0 = A ID\r\n1 = B SEARCH\r\n2 = C COUNT\r\nCell Value: 1.0 class java.lang.Double\r\nCell Value: junit class java.lang.String\r\nCell Value: 104.0 class java.lang.Double\r\n...\r\nrow 0 : [1.0, junit, 104.0]\r\n...\r\n```\r\n### Extra Features\r\n\r\nThis data provider overcomes the known difficulty of core TestNG or Junit parameter annotations: developer is\r\n[not allowed](https://stackoverflow.com/questions/16509065/get-rid-of-the-value-for-annotation-attribute-must-be-a-constant-expression-me) to redefine the dataprovider attributes like for example the data source path:\r\n\r\n```java\r\n  public static final String dataPath = \"src/main/resources\";\r\n\r\n@Test(enabled = true, dataProvider = \"OpenOffice Spreadsheet\", dataProviderClass = ExcelParametersProvider.class)\r\n  @DataFileParameters(name = \"data.ods\", path = dataPath, debug = false)\r\n  public void test(double rowNum,\r\n    String searchKeyword, double expectedCount) throws InterruptedException {\r\n    // actual code ot the  test\r\n  }\r\n```\r\nIn the above, one is only allowed to initialize the `dataPath` to a `String` (or `int`) primitive type, in particular even\r\ndeclaring the same (pseudo-const) value in a separate class:\r\n\r\n```java\r\npublic class ParamData {\r\n  public final static String dataPath = \"src/main/resources\";\r\n}\r\n```\r\nand assigning the result to the vatiable in the main test class,\r\n```java\r\npublic class FileParamsTest {\r\n  private final static String dataPath = ParamData.dataPath;\r\n```\r\nor assigning the method rerturn value to the parameter:\r\n```\r\n  public final static String dataPath = param();\r\n\r\n  public static final String param() {\r\n    return \"src/main/resources\";\r\n  }\r\n```\r\nwould fail to compile:\r\n```sh\r\nCompilation failure:\r\n[ERROR]TestNgDataProviderTest.java: element value must be a constant expression\r\n```\r\nso it likely not doable.\r\n\r\nHowever it is quite easy to allow such flexibility\r\nin the data provider class `ExcelParametersProvider` itself by\r\nadding an extra class variable e.g. `testEnvironment` which would\r\nload its value from the environment variable named `TEST_ENVIRONMENT`\r\n```java\r\nprivate final static String testEnvironment = (System\r\n    .getenv(\"TEST_ENVIRONMENT\") != null) ? System.getenv(\"TEST_ENVIRONMENT\")\r\n        : \"\";\r\n```\r\nand override the datafile path value provided in the test method annotation:\r\n```java\r\n@Test(enabled = true, dataProvider = \"OpenOffice Spreadsheet\", dataProviderClass = ExcelParametersProvider.class)\r\n@DataFileParameters(name = \"data.ods\", path = \"src/main/resources\", debug = false)\r\npublic void test(double rowNum, String searchKeyword, double expectedCount) throws InterruptedException {\r\n  dataTest(searchKeyword, expectedCount);\r\n}\r\n```\r\nin the presence of the environment `TEST_ENVIRONMENT` with the value `dev` will make it read parameters of the test from `src/main/resources/dev/data.ods` rather then `src/main/resources/data.ods`:\r\n```java\r\nif (testEnvironment != null \u0026\u0026 testEnvironment != \"\") {\r\n  filePath = amendFilePath(filePath);\r\n}\r\n```\r\n\r\nThis functionaliy is implemented directly in the `ExcelParametersProvider` provider class\r\nin a very basic fashion as shown below:\r\n\r\n```java\r\npublic class ExcelParametersProvider\r\nimplements ParametersProvider\u003cExcelParameters\u003e {\r\n\r\n  private final static String testEnvironment = (System.getenv(\"TEST_ENVIRONMENT\") != null) ? System.getenv(\"TEST_ENVIRONMENT\") : \"\";\r\n\r\n  private static String amendFilePath(String filePath) {\r\n    if (debug) {\r\n      System.err.print(\r\n        String.format(\"Amending the %s with %s\", filePath, testEnvironment));       }\r\n    // Inject the directory into the file path\r\n    String updatedFilePath = filePath.replaceAll(\"^(.*)/([^/]+)$\",\r\n    String.format(\"$1/%s/$2\", testEnvironment));\r\n    if (debug) {\r\n      System.err.println(String.format(\" =\u003e %s\", updatedFilePath));\r\n    }\r\n    return updatedFilePath;\r\n}\r\n```\r\n\r\nand take it into account to redefine the inputs during initialization:\r\n\r\n```java\r\n    filePath = String.format(\"%s/%s\",\r\n        (parameters.path().isEmpty()\r\n            || parameters.path().equalsIgnoreCase(\".\"))\r\n                ? System.getProperty(\"user.dir\")\r\n                : Utils.resolveEnvVars(parameters.path()),\r\n        parameters.name());\r\n    // if the path is relative assume it is under ${user.dir}\r\n    if (!filePath.matches(\"^[/\\\\\\\\].*\")\r\n        \u0026\u0026 !filePath.matches(\"^(?i:[A-Z]):.*\")) {\r\n      filePath = String.format(\"%s/%s\", System.getProperty(\"user.dir\"),\r\n          filePath);\r\n    }\r\n    if (testEnvironment != null \u0026\u0026 testEnvironment != \"\") {\r\n      filePath = amendFilePath(filePath);\r\n    }\r\n\r\n```\r\n\r\ntherefore the test\r\n```cmd\r\nmkdir dev\r\nmkdir src\\main\\resources\\dev\r\ncopy src\\main\\resources\\data.* src\\main\\resources\\dev\\\r\ncopy data*.* dev\r\nset  TEST_ENVIRONMENT=dev\r\nmvn test\r\n```\r\nworks as expected (the example shows debug output for Open Office data file `data.ods` originally red from `src/main/resources`):\r\n\r\n```cmd\r\nAmending the c:\\developer\\sergueik\\testng-dataproviders/src/main/resources/data.\r\nods with dev =\u003e c:\\developer\\sergueik\\testng-dataproviders/src/main/resources/de\r\nv/data.ods\r\nBeforeMethod Suite: Suite 1\r\nReading Open Office Spreadsheet: Employee Data\r\nCell Value: \"1.0\" class java.lang.Double\r\nCell Value: \"junit\" class java.lang.String\r\nCell Value: \"202.0\" class java.lang.Double\r\nCell Value: \"2.0\" class java.lang.Double\r\n```\r\nOne can easily make this behavior optional, turn the `TEST_ENVIRONMENT` envirnmant name a separate parameter or switch to store definitions of environment specifics into the property file (this is work in progress). Similar changes will be soon available to\r\n\r\n### Caller-Specific Behavior\r\n\r\nSometimes a caller-specific behavior is required from custom data provider.\r\nSee also [accessing ITestContext in DataProvider](https://automated-testing.info/t/testng-kak-poluchit-itestcontext-v-lyuboj-moment-vypolneniya-testa/25973/5)(in Russian)\r\nThis is easy to achieve, since the signature of the method one has to implement is:\r\n```java\r\n\t@DataProvider(parallel = false, name = \"OpenOffice Spreadsheet\")\r\n\tpublic static Object[][] createData_from_OpenOfficeSpreadsheet(final ITestContext context, final Method method) {\r\n\t\tif (debug) {\r\n\t\t\tSystem.err.println(String.format(\"Providing data to method: '%s' of test '%s'\", method.getName(),\r\n\t\t\t\t\tcontext.getCurrentXmlTest().getName()));\r\n\t\t}\r\n```\r\nthe test log then will include caller information:\r\n```text\r\nProviding data to method: 'testWithOpenOfficeSpreadsheet' of test 'Parse Search Result'\r\nOpening test\r\nReading Open Office Spreadsheet : test\r\n...\r\n```\r\n### Filtering Data Rows for JUnitParams\r\n\r\nIn addition to using *every row* of spreadsheet as test parameter one may create a designated column which value\r\nwould be indicating to use or skip that row of data, like:\r\n\r\n| ROWNUM |    SEARCH    | COUNT |ENABLED\r\n|--------|--------------|-------|-------\r\n| 1      | __junit__    | 100   | true\r\n| 2      | __testng__   | 30    | true\r\n| 3      | __spock__    | 20    | false\r\n| 4      | __mockito__  | 41    | true\r\n\r\nand annotate the method like\r\n\r\n```java\r\n@Test(enabled = false, singleThreaded = true, threadPoolSize = 1, invocationCount = 1, description = \"# of articless for specific keyword\", dataProvider = \"OpenOffice Spreadsheet\", dataProviderClass = ExcelParametersProvider.class)\r\n@DataFileParameters(name = \"filtered_data.ods\", path = dataPath, sheetName = \"Filtered Example\" , controlColumn = \"ENABLED\", withValue = \"true\", debug = true)\r\npublic void testWithFilteredParameters(double rowNum,\r\n    String searchKeyword, double expectedCount) throws InterruptedException {\r\n  dataTest(searchKeyword, expectedCount);\r\n}\r\n```\r\n\r\nwith this data setting only rows 1,2 and 4 from the data extract above would be used as `testWithFilteredParameters` test method parameters.\r\nThe control column itself is not passed to the subject test method.\r\nCurrently this functionality is implemented for __OpenOffice__ spreadsheet only.\r\nRemaining format is a work in progress.\r\n\r\nThis feature of storing more then one set of tests in one spreadsheet and picking the ones which column is set to a specified value\r\n has been inspired by some python [post](https://docs.pytest.org/en/latest/fixture.html#parametrizing-fixtures) and the [forum](http://software-testing.ru/forum/index.php?/topic/37870-kastomizatciia-parametrizatcii-v-pytest/)(in Russian)\r\n\r\n### Note\r\n\r\nWhen outside the project directory\r\nit is common to place the test datafile (like Excel spreadsheet) on Desktop, Downloads and other directories of the current user. However the dataprovider annotation parametes must be constant expressions and test method cannot use class variables or static methods like `File.separator` in annotation value, code like below will not compile:\r\n```java\r\nTest( dataProvider = \"Excel\", dataProviderClass = ExcelParametersProvider.class)\r\n@DataFileParameters(name = \"data_2003.xls\", path = (osName.startsWith(\"windows\")) ? \"${USERPROFILE}\" : \"${HOME}\" + File.separator + \"Desktop\" )\r\n```\r\n\r\nTo workaround this inconvenienve, the __TestNg Data Providers__ internally converts between `${USERPRFILE}` and `${HOME}` and vise versa on Linux and Mac computers therefore the expressions `path = \"${USERPROFILE}\\\\Desktop\"` or `path = \"${HOMEDIR}/Downloads\"` work across OS.\r\n\r\n### Links\r\n\r\n * [MySQL testng dataprovider](https://github.com/sskorol/selenium-camp-samples/tree/master/mysql-data-provider)\r\n * [xml testng DataProviders](http://testngtricks.blogspot.com/2013/05/how-to-provide-data-to-dataproviders.html)\r\n * [javarticles.com](http://javarticles.com/2015/03/example-of-testng-dataprovider.html)\r\n * [testng-users forum](https://groups.google.com/forum/#!topic/testng-users/J437qa5PSx8)\r\n * [passing parameters to provider via Method](http://stackoverflow.com/questions/666477/possible-to-pass-parameters-to-testng-dataprovider)\r\n * [JUnitParams](https://github.com/Pragmatists/JUnitParams) - TestNg-style `JUnitParamsRunner` and `ParametersProvider` classes.\r\n * [testng samples](https://habrahabr.ru/post/121234/)\r\n * [barancev/testng_samples](https://github.com/barancev/testng_samples)\r\n * [ahussan/DataDriven](https://github.com/ahussan/DataDriven)\r\n * [poi ppt](https://www.tutorialspoint.com/apache_poi_ppt/apache_poi_ppt_quick_guide.htm)\r\n * [paypal/SeLion data providers](https://github.com/paypal/SeLion/tree/develop/dataproviders/src/main/java/com/paypal/selion/platform/dataprovider)\r\n * [RestAPIFramework-TestNG/.../ExcelLibrary](https://github.com/hemanthsridhar/RestAPIFramework-TestNG/blob/master/src/main/java/org/framework/utils/ExcelLibrary.java)\r\n * [GladsonAntony/WebAutomation_Allure ExcelUtils.java](https://github.com/GladsonAntony/WebAutomation_Allure/blob/master/src/main/java/utils/ExcelUtils.java)\r\n * [XLS Test - Excel testing library](https://github.com/codeborne/xls-test)\r\n * [sskorol/tesst-data-supplier](https://github.com/sskorol/test-data-supplier)\r\n * [converting gradle to pom](https://stackoverflow.com/questions/12888490/gradle-build-gradle-to-maven-pom-xml)\r\n * [using gradle maven plugin to produce pom.xml](https://stackoverflow.com/questions/17281927/how-to-make-gradle-generate-a-valid-pom-xml-file-at-the-root-of-a-project-for-ma)\r\n * [Selenium data driven testing with Excel](https://www.swtestacademy.com/data-driven-excel-selenium/)\r\n * [Excel template-based report generating library](https://github.com/CourseOrchestra/xylophone)\r\n\r\n### Maven Central\r\n\r\nThe snapshot versions are deployed to `https://oss.sonatype.org/content/repositories/snapshots/com/github/sergueik/dataprovider/`\r\nThe release versions status: [Release pending](https://issues.sonatype.org/browse/OSSRH-36773?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel)\r\n\r\nTo use the snapshot version, add the following to `pom.xml`:\r\n```xml\r\n\u003cdependency\u003e\r\n  \u003cgroupId\u003ecom.github.sergueik.testng\u003c/groupId\u003e\r\n  \u003cartifactId\u003edataprovider\u003c/artifactId\u003e\r\n  \u003cversion\u003e1.3-SNAPSHOT\u003c/version\u003e\r\n\u003c/dependency\u003e\r\n\u003crepositories\u003e\r\n  \u003crepository\u003e\r\n    \u003cid\u003eossrh\u003c/id\u003e\r\n    \u003curl\u003ehttps://oss.sonatype.org/content/repositories/snapshots\u003c/url\u003e\r\n  \u003c/repository\u003e\r\n\u003c/repositories\u003e\r\n```\r\n### Apache POI compatibility\r\n\r\n  * The default version of the supported Apache POI is __3.17__.\r\n  * Older versions of the package require minor code refactoring. Note that you may also have to clear the other versions of __poi__ and __poi-ooxml__ jars from maven cache '~/.m2/repository'\r\n  * Project can be built with Apache POI 4.0.0 by modifying `poi.version` to `4.0.0` within `\u0026lt;properties\u0026gt;` node in the `pom.xml` - the profile `poi40` does not work correctly.\r\n  * Creating branches and tags is a work in progress.\r\n\r\n### Google Sheet Data Provider\r\n\r\nThis is an experimental provider based on [blog](http://www.seleniumeasy.com/selenium-tutorials/read-data-from-google-spreadsheet-using-api) how to use Google Sheets API to read data from Spreadsheet.\r\n\r\nThe test method that is about to load the parameters from Google sheet is annotated in a similar fashion as with other providers developed in this project:\r\n```java\r\n@Test(dataProviderClass = GoogleSheetParametersProvider.class, dataProvider = \"Google Spreadsheet\")\r\n@DataFileParameters(name = \"Google Sheets Example\", path = \"17ImW6iKSF7g-iMvPzeK4Zai9PV-lLvMsZkl6FEkytRg\", sheetName = \"Test Data\", secretFilePath = \"/home/sergueik/.secret/client_secret.json\", debug = true)\r\npublic void testWithGoogleSheet(String strRowNum, String searchKeyword, String strExpectedCount)\r\n    throws InterruptedException {\r\n  double rowNum = Double.parseDouble(strRowNum);\r\n  double expectedCount = Double.parseDouble(strExpectedCount);\r\n  dataTest(searchKeyword, expectedCount);\r\n\t}\r\n```\r\n\r\nHere the `name` attibute stores the name of the application,\r\n`path` is for the `id` part of the data spreadsheet URL: `https://docs.google.com/spreadsheets/d/${id}`, and optional `sheetName` stores  the name of the sheet.\r\n\r\n![Google Sheet](https://raw.githubusercontent.com/sergueik/testng-dataproviders/master/screenshots/google_sheet.png)\r\n\r\n\r\nThe path to secret file that is required to access the API, is to be defined through the `secretFilePath` attribute. Note: like with other attributes, the\r\nthe value for annotation attribute `DataFileParameters.secretFilePath` must be a constant expression.\r\nThe following would not compile:\r\n```java\r\n  private static final String SECRET_FILEPATH = Paths\r\n    .get(System.getProperty(\"user.home\")).resolve(\".secret\")\r\n    .resolve(\"client_secret.json\").toAbsolutePath().toString();\r\n\r\n  @Test(dataProviderClass = GoogleSheetParametersProvider.class, dataProvider = \"Google Spreadsheet\")\r\n  @DataFileParameters(name = \"Google Sheets Example\", secretFilePath = SECRET_FILEPATH, ...)\r\n```\r\nbut the following will:\r\n```java\r\n  private static final String SECRET_FILEPATH = \"C:/Users/Serguei/.secret/client_secret.json\";\r\n```\r\nThe secret file:\r\n```js\r\n{\r\n  \"installed\": {\r\n    \"client_id\": \"XXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com\",\r\n    \"project_id\": \"gogle-sheet-api-test-xxxxxxx\",\r\n    \"auth_uri\": \"https://accounts.google.com/o/oauth2/auth\",\r\n    \"token_uri\": \"https://oauth2.googleapis.com/token\",\r\n    \"auth_provider_x509_cert_url\": \"https://www.googleapis.com/oauth2/v1/certs\",\r\n    \"client_secret\": \"xxxxxxxxxxxxxxx\",\r\n    \"redirect_uris\": [\r\n      \"urn:ietf:wg:oauth:2.0:oob\",\r\n      \"http://localhost\"\r\n    ]\r\n  }\r\n}\r\n```\r\ncan be stored anywhere on disk outside of source control e.g. under `~/.secret/client_secret.json`.\r\nIt will be loaded once and the credential obtained from oauth would be cached and reused until expiration.\r\nThe credential appears to be valid for approximately one hour.\r\nCurrently the test opens the browser window prompting the user to confirm the access:\r\n\r\n![running test with Google Sheet Data Provider](https://raw.githubusercontent.com/sergueik/testng-dataproviders/master/screenshots/running_google_sheet_example.png)\r\n\r\nIn the future versions, parallel execution of Google Sheet parameterized tests and a more flexible caching of the access credentials is planned.\r\n\r\n### See Also\r\n  * [TestNg Excel Data Provider example](https://www.seleniumeasy.com/testng-tutorials/import-data-from-excel-and-pass-to-data-provider)\r\n  * [JUnit4, JUnit5, TestNG comparison](https://www.baeldung.com/junit-vs-testng), covers test parameteterization amond other features\r\n  * [dataprovider basics](https://howtodoinjava.com/testng/testng-dataprovider/)\r\n  * JUnit4,JUnit5, TestNG comparison, covers [parameteterized tests](https://www.baeldung.com/junit-vs-testng)\r\n  * [poire](https://github.com/ssirekumar/POIRE) - one other API on top of Apache POI to deal with office files\r\n  * parallel testing [\"best practices\"](https://docs.experitest.com/display/TE/Parallel+Tests+-+Best+Practices)\r\n  * [skip TestNG tests based on condition](https://www.lenar.io/skip-testng-tests-based-condition-using-iinvokedmethodlistener/) interface syntax sugar\r\n  * [reading data from google spreadsheet tutorial](https://www.seleniumeasy.com/selenium-tutorials/read-data-from-google-spreadsheet-using-api)\r\n  * another blog on [testng data providers backed by excel](https://www.uvdesk.com/en/blog/passing-data-dataprovider-excel-sheet-testng/)\r\n  * [apache JMeter Data-Driven Testing](https://dzone.com/articles/implementing-data-driven-testing-using-google-shee) (naturally, in groovy)\r\n  * [Google spreadsheet (older) read method using JAVA](https://dzone.com/articles/reading-data-google)\r\n  * [stackoverflow](https://stackoverflow.com/questions/32860225/read-data-from-google-spreadsheets)\r\n  * [stackoverflow](https://stackoverflow.com/questions/7566836/read-data-from-google-docs-spreadsheets)\r\n  * [Interact with Google Sheets from Java](https://www.baeldung.com/google-sheets-java-client)\r\n  * very detaled [publication](https://gist.github.com/zmts/802dc9c3510d79fd40f9dc38a12bccfc) on Token-Based Authentication and JSON Web Tokens (JWT) (in Russian)\r\n  * POI-backed Excel row/cell generic class member [serialization annotation](https://github.com/ozlerhakan/poiji) support\r\n  * [overview of TestNG testing in Java](https://habr.com/ru/post/121234/) (in Russian)\r\n  * Python resources for interacting with Office Excel file (unverified):\r\n     + https://xlsxwriter.readthedocs.io/getting_started.html\r\n     + https://www.geeksforgeeks.org/reading-excel-file-using-python/\r\n     + https://www.marsja.se/your-guide-to-reading-excel-xlsx-files-in-python/\r\n     + https://www.python-excel.org/\r\n  * [about Compound File Binary format](https://habr.com/ru/post/534126/) (in Rusian)\r\n  * [About Word files](https://habr.com/ru/post/110019/) (in Russian)\r\n  *  https://www.baeldung.com/java-thread-safety\r\n  * .net  [openmcdf](https://github.com/ironfede/openmcdf) assembly to manipulate the OLE structured storage at low level\r\n  * generic custom annotation [project](https://github.com/swtestacademy/java_annotation_example) and [documentation](https://www.swtestacademy.com/custom-java-annotations/)\r\n### Note\r\n\r\n* upgrading to TestNg from version __6.14.3__ to verson __7.5.1__ breaks certain tests:\r\n```sh\r\nmvn -f pom.xml.BROKEN clean compile test-compile test\r\n```\r\n```text\r\n[ERROR] CommonTest.java:[55,41] cannot find symbol\r\n[ERROR] symbol:   method getParameters()\r\n[ERROR] location: class org.testng.xml.XmlTest\r\n[ERROR] CommonTest.java:[164,49] cannot find symbol\r\n[ERROR] symbol:   method getMethod()\r\n[ERROR] location: variable testNGMethod of type org.testng.ITestNGMethod\r\n[ERROR] CSVProviderTest.java:[62,33] cannot find symbol\r\n[ERROR] symbol:   method getParameters()\r\n[ERROR] location: class org.testng.xml.XmlTest\r\n```\r\nin the code\r\n```java\r\nITestResult iTestResult;\r\nITestNGMethod testNGMethod = iTestResult.getMethod();\r\nMethod testMethod = testNGMethod.getMethod();\r\n```\r\nand\r\n\r\n```java\r\nfinal Map\u003cString, String\u003e parameters = \r\n(((TestRunner) context).getTest()).getParameters();\r\n```\r\n\r\nComparison of the version __6.3__ [interface](https://javadoc.io/doc/org.testng/testng/6.3/org/testng/ITestNGMethod.html)\r\nwith version __7.5__ [interface](https://javadoc.io/doc/org.testng/testng/7.5/org/testng/ITestNGMethod.html)\r\n\r\n\r\nComparison of the version __6.3__ [interface](https://www.javadoc.io/doc/org.testng/testng/6.3/org/testng/xml/XmlTest.html)\r\n\r\nwith  version __7.5__ [interface](https://www.javadoc.io/doc/org.testng/testng/7.5/org/testng/xml/XmlTest.html)\r\n\r\n### TODO\r\n\r\non Linux develpment machine, seem to not be able to launch google tests. After authenticaling o Windows machine, issue disappears\r\n```sh\r\n[ERROR] org.testng.TestNGException:\r\n[ERROR] Cannot find class in classpath: com.github.sergueik.testng.ExcelProviderTest\r\n```\r\n### Author\r\n[Serguei Kouzmine](kouzmine_serguei@yahoo.com)\r\n  \r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsergueik%2Ftestng-dataproviders","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsergueik%2Ftestng-dataproviders","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsergueik%2Ftestng-dataproviders/lists"}