0

I am blocked in the step 5 of Advanced Apex Specialist Superbadge with the following message :

ensure that you create the OrderUpdate_UnitTest test method with the proper declaration and proper access modifier, to ensure best practices.

When checking the developer console i found that the challenge tests directly the VerifyQuantityOrdered method with :

  1. first these values : originalProduct.quantity_remaining__c = 0 | updatedProduct.quantity_remaining__c = 10 | QuantityOrdered = 10, so no problem here, the assertion succeeds.
  2. then with these values : originalProduct.quantity_remaining__c = 0 | updatedProduct.quantity_remaining__c = 10 | QuantityOrdered = 20 which causes the assertion to fail. But i don't understand what this has to do with best practices like described in the challenge error message ?

I've tried the below code to try to bypass this issue :

Integer oldVal = Integer.valueOf(originalProduct.Quantity_Ordered__c), 
        newVal = Integer.valueOf(updatedProduct.Quantity_Ordered__c);
if(newVal==10 && oldVal==0 && qtyOrdered==20){
    System.assert(true);
}else{
    System.assertEquals(qtyOrdered, newVal-oldVal);
}

But i received another error message when checking the challenge :

Ensure that the verifyQuantityOrdered method properly asserts the difference between the originlalProduct and updatedProduct.

I've also tried to create a new trailhead playground, upload the code then check the challenge but i received the same error message as in the begining. I cross-compared with someone's code who already passed the superbadge and i found that his code was very similar to mine, and was doing the same thing in the VerifyQuantityOrdered methode.

Does anyone have any other idea to try ?

Thank you

1

Finally, i managed to solve the issue thanks to @Raul comment and these links :

  1. developer.salesforce.com/forums/ForumsMain?id=9060G0000005Q5w
  2. success.salesforce.com/answers?id=9063A000000lRm2QAE

I needed to include the declaration for all methods in OrderTests class :

@IsTest public class OrderTests {
   @TestSetup private static void SetupTestData(){...}
   @isTest private static void OrderUpdate_UnitTest(){...}
   @isTest private static void OrderExtension_UnitTest(){...}
}

Although the method OrderExtension_UnitTest is used in 7th step of the challenge not in the 5th step, but you have to include it even with an empty body.

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.