You need to sign in to do that
Don't have an account?
Matthew Holliday 8
"No Apex test class named 'TestRestrictContactByName' was found" even though class exists.
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?
The class is visible to all user profiles.
"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.
Have you run all test before submit.
Previously I am also facing same problem. And that I was doing following steps :
Salesforce Quick Findbox - > write "apex test Execution" - > select tests Buttton and find your class here.
I thing the class can be shown here. If the test class is find then execute it and then go to Dev console then search the test class.
If you are not still find the class name in test execution then open your class in read mode and there is a button run test. You can run your test class from here.
Thanks.
Tiago Welter
public class TestRestrictContactByName {
@isTest static void TestRestrictContactByInvalidName() {
Contact cont = new Contact(LastName='INVALIDNAME');
Test.startTest();
Database.SaveResult result = Database.insert(cont,false);
Test.stopTest();
System.assert(!result.isSuccess());
System.assert(result.getErrors().size() > 0);
System.assertEquals('The Last Name "'+cont.LastName+'" is not allowed for DML',
result.getErrors()[0].getMessage());
}
}