0

I am trying to complete the challenge number#5 on the Advanced Apex Specialist Super badge and I am stuck with an error. I am getting an error stating that the test method doesn't have proper declaration or access modifier but the test method does have all of that. Not sure how to proceed here.

Error Message: enter image description here

Test class signature that I have tried with and all have resulted in the same error:

Option1

@isTest static void OrderUpdate_UnitTest() { ... }

Option2

@isTest private static void OrderUpdate_UnitTest() { ... }

Option3

@isTest(seeAllData=false) private static void OrderUpdate_UnitTest() { ... }

Option4

static testMethod void OrderUpdate_UnitTest() { ... }

Option5

private static testMethod void OrderUpdate_UnitTest() { ... }

EDIT

TestDataFactory.VerifyQuantityOrdered

public static void VerifyQuantityOrdered(Product2 originalProduct, Product2 updatedProduct, Integer qtyOrdered) {
       system.assert(updatedProduct.Quantity_Ordered__c == originalProduct.Quantity_Ordered__c+qtyOrdered);
    }
  • try using @IsTest – Caspar Harmer Jul 29 at 1:59
  • @CasparHarmer, I have tried that but that didn't help out either. – Sam Jul 29 at 3:34
  • 1
    Open your debugger console and run the verify again. Often you'll see what they want in the debug output. – Caspar Harmer Jul 29 at 6:38
0

Have you tried making the Test Class public or the methods themselves public or global?

Not sure how they verify these tests, but assume its a mixture of Metadata API and actually running the tests themselves, and could be the latter not being possible if they are all private. If you have already had tests validated by Trailhead in earlier challenge steps without having to use public though, this answer is probably on the wrong track.

  • Yes, I have tried all possible combination of making the method and class public. But the error clearly states to follow 'Best Practices' and the best practices indicate to use private as the modifer and have @isTest instead of testMethod. – Sam Jul 29 at 3:34
  • Yeah, agree with you on that. Ideally it should be @isTest private static void. Out of interest, what happens if you remove whitespace between () and { so: OrderUpdate_UnitTest(){ – aidan Jul 29 at 4:17
  • yup, I tried that as well.. But no luck. – Sam Jul 29 at 4:29
  • I would recommend logging a support ticket, there is a trailhead support team that are supposed to assist with troubleshooting badges, although in my experience you can wait up to 3 weeks for a response depending on how busy they are. Other avenues of exploration are: -create a new trailhead playground and paste the code back in -turn on logging and inspect in detail whether there is an error payload returned when you check the challenge – aidan Jul 29 at 4:39
0

There are 3 things that helped in passing this challenge

  1. Created another trailhead playground and moved the code to that org.
  2. Added the private modifier to the testSetup method.
  3. Added the dummy OrderExtension_UnitTest() method.

protected by David Reed Jul 30 at 23:46

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.