1

I have a field in an if condition and I want to validate it in my test method. This is the if method in my class:

 if ( String.isNotBlank(account.Phone__c)

I have a method in my test class in which I have already populated the field in this way:

testAccount.Phone__c = '654123367';

How I can recall it in my test class? without to leave my fill field.

  • 2
    What's your question exactly? Please edit your post to make your question more clear. – Adrian Larson Jan 25 '17 at 12:49
0

You can use @testSetup method that will populate records for you.

In positive unit test 1 you can just query the record and start your test execution.

For Negative scenario unit test method, query the record, make its value as null and then call your testable method.

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.