0

i have an issue, i want to increase in my test class this code:

 if(!String.isBlank(account.A_Field_Picklist__c) &&
 !ClassOfCostants.NotValutable.equalsIgnoreCase(account.A_Field_Picklist__c) )

The condition over it is an if and it's blue, i tried this test method:

static testMethod void test() {

    Test.startTest();

    Account a= new Account();

    a.A_Field_Picklist__c= ' ';
    a.A_Field_Picklist__c= 'A VALUE';

    insert(a);

    Test.stopTest();

    }

But it didn't work. The code coverage is at 1%. Thnaks In advance to everyone that will reply.

0

You can try out this approach.

First insert the record with blank and next, update the same record with some valid data.

static testMethod void test() {
    Test.startTest();
    Account a= new Account();
    a.A_Field_Picklist__c= '';
    insert(a);

    Account aObj = [SELECT A_Field_Picklist__c FROM Account WHERE Id=:a.Id];

    aObj.A_Field_Picklist__c= 'A VALUE';
    update aObj;   
    System.assertEquals (....);
    Test.stopTest();

}

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.