You need to sign in to do that
Don't have an account?
Sue Irvine
No Apex test class named 'TestRestrictContactByName' was found
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); } }
Try this
Tiago Welter