• Dan Wuensch
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
On Step 5 of Advanced Apex Specialist (Increase test coverage with unit tests), I am getting the following error when checking the challenge:

Challenge Not yet complete... here's what's wrong: 
Ensure that you create an instance of product2Extension.

Reviewing the logs seems to point to a problem in a different area than testing Product2Extension.

"Assertion Failed: Expected: 10, Actual: 20" - TestDataFactory.VerifyQuantityOrdered line 15

My unit tests that use VerifyQuantityOrdered as requested pass and are working as intended. My debug statements in TestDataFactory for setting up test data and in the unit test in OrderTests are not being logged out in this anonymous block execution, pointing to a direct invocation of TestDataFactory.VerifyQuantityOrdered directly by the Trailhead anonymous Apex, passing two Products and a qtyOrdered value of 20. The first Product passed has a Quanity_Ordered__c value of 0 and the updated product passed has a Quanity_Ordered__c value of 10. Since the qtyOrdered passed is 20, the expectation is:

public static void VerifyQuantityOrdered(Product2 originalProduct, Product2 updatedProduct, Integer qtyOrdered) {
     System.assertEquals(updatedProduct.Quantity_Ordered__c, (originalProduct.Quantity_Ordered__c + qtyOrdered));
}

0 + 20 is not equalling 10 as expected. It seems to me as though the anonymous block in this step is passing the wrong value for updatedProduct.Quantity_Ordered__c.

Any recommendations?
On Step 5 of Advanced Apex Specialist (Increase test coverage with unit tests), I am getting the following error when checking the challenge:

Challenge Not yet complete... here's what's wrong: 
Ensure that you create an instance of product2Extension.

Reviewing the logs seems to point to a problem in a different area than testing Product2Extension.

"Assertion Failed: Expected: 10, Actual: 20" - TestDataFactory.VerifyQuantityOrdered line 15

My unit tests that use VerifyQuantityOrdered as requested pass and are working as intended. My debug statements in TestDataFactory for setting up test data and in the unit test in OrderTests are not being logged out in this anonymous block execution, pointing to a direct invocation of TestDataFactory.VerifyQuantityOrdered directly by the Trailhead anonymous Apex, passing two Products and a qtyOrdered value of 20. The first Product passed has a Quanity_Ordered__c value of 0 and the updated product passed has a Quanity_Ordered__c value of 10. Since the qtyOrdered passed is 20, the expectation is:

public static void VerifyQuantityOrdered(Product2 originalProduct, Product2 updatedProduct, Integer qtyOrdered) {
     System.assertEquals(updatedProduct.Quantity_Ordered__c, (originalProduct.Quantity_Ordered__c + qtyOrdered));
}

0 + 20 is not equalling 10 as expected. It seems to me as though the anonymous block in this step is passing the wrong value for updatedProduct.Quantity_Ordered__c.

Any recommendations?