• 25 Points
  • Member since 2016

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
  • 1
I have this very simple class..  
trigger RestrictContactByName on Contact (before insert, before update) {
    //check contacts prior to insert or update for invalid data
    For (Contact c : Trigger.New) {
        if(c.LastName == 'INVALIDNAME') {   //invalidname is invalid
            c.AddError('The Last Name "'+c.LastName+'" is not allowed for DML');
.. and the corresponding Test Class:  
private class TestRestrictContactByName {

	@isTest static void metodoTest() {
		List listaContatti = new List();
		Contact c1 = new Contact(FirstName='Francesco', LastName='Riggio');
		Contact c2 = new Contact(LastName = 'INVALIDNAME');
		//insert listaContatti;
		// Perform test
        Database.SaveResult [] result = Database.insert(listaContatti, false);
		c1.LastName = 'INVALIDNAME';
		update c1;

When I run the Test class from the Developer Console I get 100% of coverage on the RestrictContactByName class but, when I check the challenge on the trailhead it returns the error:

Challenge not yet complete... here's what's wrong: The 'RestrictContactByName' class did not achieve 100% code coverage via your test methods

Has someone had my same issue?
Join the Salesforce Community Cloud 2015 Innovation Award Winner and build the next generation of digital experiences powered by the Salesforce platform.  7Summits is looking for Salesforce talent including: 
  • Salesforce Developer - Chicago IL, Milwaukee WI or Remote: http://7summitsinc.applytojob.com/apply/9QiHxR
  • Salesforce Technical Architect - Chicago IL, Milwaukee WI or Remote: http://7summitsinc.applytojob.com/apply/8aEM4u
  • Salesforce Front End Developer -  Chicago IL, Milwaukee WI or Remote: - http://7summitsinc.applytojob.com/apply/BwSGOC
  • Salesforce Sales Engineer - Chicago IL, Milwaukee WI or Remote: http://7summitsinc.applytojob.com/apply/ry8VAL
  • Salesforce Business Analyst / Admin  -  Chicago IL, Milwaukee WI or Remote: http://7summitsinc.applytojob.com/apply/sufDyx
  • Salesforce Alliance Manager - San Francisco : http://7summitsinc.applytojob.com/apply/GsQ5J5 
We are a passionate team of strategists, designers, and developers that believe in unleashing people’s potential to create, innovate, and compete in entirely new ways. See our work at:
  • Plus Relocation Community: https://vimeo.com/139293581
  • SeaRay Boat Owners Community: https://vimeo.com/151956674
Ascend with the best—come see what we’re all about!