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}.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.