简体   繁体   English

Junit断言

[英]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 : 从表中,我得到String的列表,并想检查当val!=“ A”时,表列表中是否存在字符串“ x”:

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 ? 如何使用断言检查字符串X是否存在?

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")); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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