function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Vipin K 23Vipin K 23 

Challenge Not yet complete... here's what's wrong: Ensure that you create the OrderUpdate_UnitTest test method with the proper declaration and proper access modifier, to ensure best practices.


User-added image


Code base:
@isTest(seeAllData =False)
public class OrderTests {
    
    @testSetup 
    public static void SetupTestData(){
        TestDataFactory.InsertTestData(1);
    }

    Static testmethod void OrderUpdate_UnitTest(){
        Test.startTest();
        Product2 originalproduct = [SELECT Id, Family, Name, Quantity_Ordered__c, Quantity_Remaining__c FROM Product2 LIMIT 1];
        Order od = [SELECT id, Status FROM Order LIMIT 1];
        
        
        od.status = constants.ACTIVATED_ORDER_STATUS;
        Update od;
        
        
        Product2 updatedProduct = [SELECT Family,Id,Name,Quantity_Ordered__c ,Quantity_Remaining__c FROM Product2 WHERE id=:originalproduct.Id LIMIT 1];
        
        TestDataFactory.VerifyQuantityOrdered(originalproduct,updatedProduct,Constants.DEFAULT_ROWS);
        Test.stopTest();
    }
}
Thanks in advance.
Irina Aristova 10Irina Aristova 10
Having same problem, tried different declaration and modifies, nothing worked.
Vasilina Veretennikova 8Vasilina Veretennikova 8
The same issue. Please find similar topics:

https://developer.salesforce.com/forums/?id=9060G0000005Q5wQAE
https://developer.salesforce.com/forums/?id=9062I000000g6OIQAY
https://success.salesforce.com/answers?id=9063A000000a1tLQAQ

 
Vipin K 23Vipin K 23
Finally got the solution, created a case with salesforce trailahead support and helped me figured out what I was missing.
Use the below code it worked for me 
@isTest (seeAllData=false)
private class OrderTests {
    @testSetup
    static void SetupTestData() {
        TestDataFactory.InsertTestData(20);
    }
   @isTest private static void orderUpdate_UnitTest() {
        Order selectedOrder = [Select name,Status, Id from Order limit 1];
        Product2 oldProd = [Select Quantity_Ordered__c, Name, Id from Product2 limit 1];
        
        selectedOrder.Status = Constants.ACTIVATED_ORDER_STATUS;
        update selectedOrder;
        
        Product2 updatedProd = [Select Quantity_Ordered__c, Name, Id from Product2 limit 1];
        
        TestDataFactory.VerifyQuantityOrdered(oldProd,updatedProd,Constants.DEFAULT_ROWS);
    }
// This was missing for my code 
 @isTest private static void orderExtension_UnitTest() {}
}

Thanks,
Vipin