I have a test suite in KS which validates a website with parameterized data(FirstName, LastName, Phone#, City etc…)which means, every time I run my test suite it looks for the csv file which has multiple rows and columns in order to read the contents and submit the form vis website.
My question is, am planning to do CICD where whenever my developers push and commit any changes to branch my test build in Jenkins will invoke automatically and run the test. But my concern is, I don’t want my test build to consume same test data from csv rather it should be a loop. To cut it short, every time it should take different set of test data from my csv file. Any thoughts will be helpful.
So the CSV file would have headers as FirstName, LastName, City, Phone#, PostalCode and there will be around 20 rows(ie, 20 test data) in a csv/xls file. I guess you got my question. Still, trying to clarify more - I would like to see whenever Jenkins test build gets invoked how it will not end up choosing the same row#(same test data). Because, when my Jenkins test build got invoked for the first time it would have chosen row#1…now when the job got invoked again for the 2nd time, how will I make sure it won’t chose again the row#1 but row#2 ?
when my Jenkins test build got invoked for the first time it would have chosen row#1…now when the job got invoked again for the 2nd time, how will I make sure it won’t chose again the row#1 but row#2 ?
def dataIndex = 0
if (System.getenv("dataIndex") != null) {
dataIndex = Integer.parseInt(System.getenv("dataIndex"))
}
// you use dataIndex to retrieve the row
I need this because, the outcome of my script is to read the data(for example, ID) from csv/xls and create an ID with the same name as mentioned in row#1. So, when my script runs for the second time, I want my script to look at row#2 for retrieving the ID2 and create the ID with the same name. I cannot afford having duplicate IDs as it will impact the system. Hope this helps
I like this idea and Thanks for sending this out. But, as I already mentioned I do not want to hard code the dataIndex value to the row number from which I need data. Because, if that is the case I can just put one row of test data and ask my script to always look for it whenever Jenkins test build is triggered.
I’m looking for something like…if my test data file has 5 rows, whenever Jenkins test build is triggered my test script should use ‘next’ test data. And this should happen automatically. In the example you mentioned, I have to go to Jenkins every time and set the value to the row number for the one which I want to use. What am planning is a CICD workflow which should not have any manual intervention.
Sorry, is BUILD_NUMBER. Pay attention that this is Jenkins specific, for other CI’s may be different or not available at all.
The current build number, such as “153”
A bit of math will be needed also, if let’s say the data has only 5 rows, since the build it will continuously increase with each execution … but that should be trivial to do it, e.g: