I automate tests using SilkTest and Java. In this keyword, I get the list and I compare it to the one expected. Is there a way to optimize my code since I have declared each list multiple times.
public void vérification_des_listes(String listAttendu) {
final String[] list1 = listAttendu.split(";", -1);
final ArrayList<String> listExpected = new ArrayList<>();
for (final String I : list1) {
listExpected.add(I);
}
System.out.println(listExpected.toString());
final Object[] list2 = desktop.<DomListBox>find("BrowserApplication.BrowserWindow.Personne.Titre_champ").getItems().toArray();
final ArrayList<String> listFound = new ArrayList<>();
for (final Object E : list2) {
listFound.add(E.toString());
}
System.out.println(listFound.toString());
assertTrue("", listExpected.equals(listFound));
}