This question already has an answer here:
- How do I compare strings in Java? 23 answers
I am obtaining a value from a cell in an excel file and storing it to a string var.
I can print the string var to the console.
However, I cannot identify the content of the string in an If statement.
What's going on?
@Test(dataProvider="sourceFromExternalExcelFile")
public void testcase(String blockStatus) throws IOException, InterruptedException, JSONException {
// as expected, returns in the console: blockStatus is blocked
System.out.println("blockStatus is " + blockStatus);
// unexpected, value of blockStatus is not identified as: blocked
if (blockStatus == "blocked") {System.out.println("IDENTIFIED");}
I am even able to create a new string comprising of string: blockStatus, print this new string, but then unable to use the value of a the new string in an If statement.
Could this be something to do with running the method once per entry in the dataProvider?
Thanks
Aucun commentaire:
Enregistrer un commentaire