1

I want to pass the test case assertEquals with String 'success'. But the value getting from the query like {success}. How do I convert 'success' to {success}

System.assertEquals('success'', myMap.keySet());

in myMap, the key is 'success' But when I use it to myMap.KeySet(), it is returning {success}.

0

2 Answers 2

2

keySet() returns the Set which is represented by {...} in debug (same with list also). You should rather check if success exists in set:

System.assert(myMap.keySet().contains('success'));
2

You would want to compare the set to another set:

System.assertEquals(
  new Set<String>{'success'}, 
  myMap.keySet(),
  'Expected the set to contain one value called success'
);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .