gpt4 book ai didi

java - Junit 断言

转载 作者:行者123 更新时间:2023-12-02 00:37:14 30 4
gpt4 key购买 nike

从表中,我获取字符串列表,并想检查当 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 ?

}
}

}

如何使用断言检查字符串 X 是否存在?

最佳答案

也许是这样的

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

关于java - Junit 断言,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7446595/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com