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
Isabel Ba.Isabel Ba. 

TRAILHEAD: Test the Change Event Trigger The test method doesn’t insert an opportunity with the correct fields. Double-check the Name, StageName, and CloseDate and try again.

When I try to validate my challenge described in the module, I get the following error:
"The test method doesn’t insert an opportunity with the correct fields. Double-check the Name, StageName, and CloseDate and try again."

the challenge asks that the method create an opportunity with the following fields.
Name: 'Sell 100 Widgets'
StageName: 'Prospecting'
CloseDate: Date.today().addMonths(3)

and my test code is:

 insert new Opportunity(Name= 'Sell 100 Widget ', 
                          StageName='Prospecting', 
                          CloseDate =Date.today().addMonths(3));    

and my trigger code is:
 if ((header.changetype == 'UPDATE') && (event.isWon == true)) 
 

Any idea what could be wrong?

Sai PraveenSai Praveen (Salesforce Developers) 
Hi,

Please note that Questions about how to pass Trailhead challenges are not on topic, because these challenges are intended to be independent demonstrations of your abilities.
Trailhead Help (https://trailhead.salesforce.com/en/help?support=home) can provide assistance for situations where Trailhead does not appear to be functioning correctly.

You can reach out to them if this is the case.Hope above information helps.

Please mark as Best Answer so that it can help others in future.