• Lalit Gupta 37
  • NEWBIE
  • 5 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies
Hello,
In the exercise "Create a unit test for a simple Apex trigger" , here is the code I wrote and for some reason it keeps giving me an Assertion failed 
@ line 24. Can you please help determine the reason?

@isTest
private class TestRestrictContactByName
 {
    @isTest static void TestMethodRestrictContact() {
        // Test data setup
        // Create an Account and its contact with Last Name = INVALIDNAME
        Account acct = new Account(Name='Test Account');
        insert acct;

List <Contact> contactlist = new List <Contact>();

Contact cont1 = new Contact(FirstName='Test1',LastName='INVALIDNAME',Email='test1@invalid.com',AccountId=acct.Id);
contactlist.add(cont1);
Contact cont2 = new  Contact(FirstName='Test2',LastName='VALIDNAME',Email='test2@valid.com',AccountId=acct.Id);
contactlist.add(cont2);

Test.startTest();
    try {
        insert contactlist;
        }
    Catch (DMLException exp) {
        for(integer i = 0; i < 2; i++) {
    //System.assert(exp.getMessage().contains('The Last Name "'+Contactlist[i].LastName+'" is not allowed for DML'));
    System.assert(exp.getMessage().contains('The Last Name INVALIDNAME is not allowed for DML'));
        }
    }
Test.stopTest();
}
}

 
I am currently on step 5 of the superbadge, and I'm getting this error:

Challenge Not yet complete... here's what's wrong: 
The record type 'Residential Opportunity' has the incorrect business process assigned.

Obviously I've set up the Residential Opportunity record type. I also created a sales process called Residential Opportunities and used the stages in the guidelines, and I DID assign it to the Residential Opportunity record type. I'm not sure where I'm going wrong here. Is this a bug?User-added image