How To cover below lines in test class.

    String iso = userInfo.getDefaultCurrency();
    String symbol = null;
    if(iso == 'EUR'){symbol='€'; }
    else if (iso=='ALL') { symbol='Lek'; } 
    else if (iso=='USD') { symbol='$'; } 
    else if (iso=='ARS') { symbol='$'; } 
    else if (iso=='AWG') { symbol='ƒ'; } 
    else if (iso=='AUD') { symbol='$'; } 
    else if (iso=='BSD') { symbol='$'; } 
    else if (iso=='BBD') { symbol='$'; }
    return symbol;
  • 1
    @Kedia what have you tried so far? – Boris Bachovski Nov 27 '14 at 5:46
  • I write above code in apex class method now i want to cover above code in test class. – Ravikant Kedia Nov 27 '14 at 5:58
  • 1
    Hello Ravikant and welcome to Stackexchange! If you want to get an answer faster, better and more complete you should consider explaining you problem a bit more than "how to do it?". Simply explain your problem and show us what have you done so far in order to solve your problem. Questions with bunch of code and question like "can you help me?" remain unanswered most of the time. Help us us to help you, make your problem easier to understand – Novarg Nov 27 '14 at 6:57

In common, test class should create its own test user, simply to cover your code, you can create one user without any currency code above.

But with best practice, i suggest you should create 9 users with diffreent currency code for test, Let the test really make sence.

  • How i can create user using currency value can you tell me one example. – Ravikant Kedia Nov 27 '14 at 6:35
  • create user with this field :DefaultCurrencyIsoCode='sth'. Here is a full example salesforce.com/us/developer/docs/apexcode/Content/… – ling Nov 27 '14 at 6:45
  • I am getting error like Invalid field DefaultCurrencyIsoCode for SObject User – Ravikant Kedia Nov 27 '14 at 7:42
  • well, maybe you can start checking multiple currencies feature is enbaled for your org. DefaultCurrencyIsoCode only applicable for organizations that use multiple currencies. – ling Nov 27 '14 at 9:58

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.