How to execute a single script multiple times with different input cases?

Hello everyone,
Is there any way to repeat a single process multiple times with different inputs.
Like we have an login screen of any application and we want to test it with all possible input cases then how to automate this test with different inputs every time with out making change to our script.

Thanks,
jitender.

@jitenderbhardwaj
You can use dataprovider available in TestNG.

Can you elaborate a bit about dataprovider? @salmanchauhan
How to use it and where to find it.

@jitenderbhardwaj Below is the simplest code snippet.

 @DataProvider(name = "test1")
       public static Object[][] primeNumbers() {
          return new Object[][] {{2, true}, {6, false}, {19, true}, {22, false}, {23, true}};
       }

       // This test will run 4 times since we have 5 parameters defined
       @Test(dataProvider = "test1")
       public void testPrimeNumberChecker(Integer inputNumber, Boolean expectedResult) {
          System.out.println(inputNumber + " " + expectedResult);
   }
1 Like