-1

How to run your Test with Byte Array values from 00 to FF ( Testng) Java

I want to run my Tests with byte array values from 00 to FF and verify my results based on Each values.

I have used CSV and Excel sheet ( or testng DataProvider) to add byte array data and run all tests. this way consist of total 256(00-255) tests and i have to add entry for each byte array value.

is there any way i can all my tests in Loop with Byte array value from 00 to FF?

1 Answers1

0

EDIT: After more precise comment:

You can generate all values in a byte by this code and pass the hex value to your test called runtest in this sample code.

for(int i=0;i<=255;++i)
{
     runtest(Integer.toHexString(i));
}

Since you want to loop through values from 0-255 there is no need to use a byte array, since one byte fits all your values.

Documentation of Integer.toHexString(int i) 1

Hannes
  • 306
  • 2
  • 10
  • Thanks Hannes. actually i want Hex Values to be passed in my every test. I am using Testng suite to run my tests and i am picking all the values of Hex bytes from excel file. I will reiterate same exercise 256 time for diff values. total 256 testcases. – user3322951 May 08 '21 at 00:54
  • Now I understand. I've edited the answer. That sould fit your needs. – Hannes May 08 '21 at 01:00
  • For my further usages i will use CSV file to read data from there. CSV file with 00 to FF column and i will run my tests around those values. i do not think i can run my testng tests inside for loop. – user3322951 May 08 '21 at 01:22
  • @user3322951 you could use this loop to generate the array as pass it to your test using a data provider – Gautham M May 14 '21 at 11:16