简体   繁体   中英

Junit assertions

From a Table, I get list of String's and would like to check that when val!= "A" , a string "x" exist in the list of table :

for (int i = 0; i < NbRow; j++)
      {


        if (val[i] == "A")
        {
         assertFalse("");

        }
        else
        {

          list.add(myTable.getValue(j, 0)); 

          //need to check here the string exists in the list using assertTrue ?

        }
      }  

      }

How do I check that string X exists using assertion ?

Perhaps something like

List<String> list = new ArrayList<String>();
for(int i=0;i<NB_Row;i++){
    list.add(myTable.getValue(row,col))
}
Assert.assertTrue(list.contains("file2"));

如果字符串在列表或集合中,则

assertTrue(list.contains("rohg")); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM