Data-Driven Tests with DataProvider — Selenium Automation (Java)
TestNG's @DataProvider runs one test method with many input rows — perfect for validation rules, roles, or locales. Feature How Inline data return new Object[][] { {"a", 1}, {"b", 2} }; External data read CSV/JSON/Excel in the provider Parallel rows @DataProvider(parallel = true) + data-provider-thread-count in testng.xml Shared provider dataProviderClass = TestData.class Readable names implement ITest or include the case name in the data Keep data close to the test when it's small; move it to resource files when it is large or owned by testers.
Key Takeaways
One test method + a DataProvider covers many input cases.
Include the input in assertion messages so failures are easy to read.
Load larger data sets from CSV/JSON resources.
Run provider rows in parallel only when the test is fully isolated.