This project belongs to a series of posts on my blog about this subject. Please feel free to contribute and send your pull requests with either better or new ways to manage data.
As it is a testing project you don't need too much. You will need the following:
- IDE of your choice
- Java JDK 23+
- Maven
Approach | Test class | Support classes |
---|---|---|
Local solution to read a property file | PropertiesFileTest.java | ReadProperties.java, and data.properties |
Solution using Owner library | PropertiesFileWithOwnerTest.java | PropertiesManager.java, PropertiesFile.java, and data.properties |
Approach | Test class | Support classes / files |
---|---|---|
Using the @ValueSource annotation |
JUnitValueSourceTest | |
Using the @MethodSource annotation with internal data methods |
InternalMethodSourceTest.java | |
Using the @MethodSource annotation with external data methods |
ExternalMethodSourceTest.java | ExternalData.java |
Using the @ArgumentsSource annotation with an argument provider |
ArgumentProviderTest.java | ProductsDataArgumentProvider.java |
Using the @CsvFileSource annotation with an external csv file |
CsvFileSourceTest.class | products.csv |
Using the @CsvSource annotation with the CSV notation as data provider |
CsvSourceTest.class |
Approach | Test class | Support classes / files |
---|---|---|
Using the @Parameters annotation |
TestNGParametersTest.java | testng_data_parameters.xml |
Using the local @DataProvider |
TestNGLocalDataProviderTest.java | |
Using an external @DataProvider |
TestNGExternalDataProviderTest.java | TestNGDataProvider.java |