Junit test case for method and inside for-loop

public Set<String> extractServiceNames(String servicesArray){         String removeArry = servicesArray.substring(servicesArray.indexOf('['), servicesArray.lastIndexOf(']') + 1);                  serviceNames = new LinkedHashSet<>();             JSONArray jsonarray = new JSONArray(removeArry);              for (int i = 0; i < jsonarray.length(); i++) {                 JSONObject jsonobject = jsonarray.getJSONObject(i);                 serviceNames.add(jsonobject.getString("serviceName"));             }         return serviceNames;     } 

I’m new to Junit. I want to write test cases for method, loops. Do we have any guidelines or procedures to write test cases for method, for loop? Can anyone explain this code?

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.