• Tiago Welter
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
I get the following message when checking the challenge for the "Testing Apex Triggers" section:

"Challenge Not yet complete... here's what's wrong: 
No Apex test class named 'TestRestrictContactByName' was found"

I've verified that there is a public class with this exact name. What am I missing?
 
@isTest
public class TestRestrictContactByName {
    public static testMethod void TestRestrictContactByNameTrigger(){
        Contact c = new Contact(LastName = 'INVALIDNAME');
    Test.startTest();
        Database.SaveResult result = Database.insert(c,false);
        Test.stopTest();
        
        System.assert(!result.isSuccess());
    }

The class is visible to all user profiles. 
I'm trying to complete the "Testing Apex Triggers" challenge. My Test class is working and has 100% code covereage but Trailhead keeps telling me "No Apex test class named 'TestRestrictContactByName' was found". There is no namespace in my de org. I'd appreciate any help in completing this challenge - it looks like it should be working. Thanks!
 
@isTest
public class TestRestrictContactByName {
    @isTest static void TestRestrictContact() {
             
        Contact con2 = New Contact(lastname='INVALIDNAME', firstname='tom');
        
        Test.startTest();
        Database.saveresult result = Database.insert(con2, false);
        Test.stopTest();

        System.assert(!result.isSuccess());
        System.assert(result.getErrors().size() > 0);
        System.assertEquals('The Last Name "'+con2.lastname+'" is not allowed for DML',
                             result.getErrors()[0].getMessage());
    }
    @isTest static void TestValidContact(){
        Contact con = new Contact(lastname='jones',firstname='tom');

        Test.startTest();
        Database.saveresult result2 = Database.insert(con,false);
        Test.stopTest();
        System.assert(result2.isSuccess());
        System.assert(result2.getErrors().size() <1);
    
}    
}