You need to sign in to do that
Don't have an account?

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.
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.
https://developer.salesforce.com/forums/?id=9060G0000005Q5wQAE
https://developer.salesforce.com/forums/?id=9062I000000g6OIQAY
https://success.salesforce.com/answers?id=9063A000000a1tLQAQ
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