• Isabel Ba.
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

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?

Hi,
my challenge when doing the above mentioned module fails with 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 requirement is as follows:
In the test method, create an opportunity with the following fields.
Name: 'Sell 100 Widgets'
StageName: 'Prospecting'
CloseDate: Date.today().addMonths(3)


And the code is this:
    Opportunity opp =  new Opportunity(Name='Sell 100 Widgets',
           CloseDate=System.Date.today().addMonths(3),
           StageName='Prospecting');
    insert opp;


Any idea what could be wrong?