Let me preface this by saying that I am very unfamiliar with Salesforce. I have written a set of small discovery type tests to try and feel my way through the syntax and how things work, but I am getting stuck with no values coming back from my queries.
@isTest
private class SmartSearchTests {
//works exactly as expected
static testMethod void trueIsTrue() {
System.assertEquals(true, true);
}
//works as expected
static testMethod void trueIsNotTrue() {
System.assertNotEquals(true, false);
}
//Same value 0
static testMethod void canGetASmallListOfContacts() {
List<Contact> ccs = [SELECT Id from Contact Limit 10];
System.assertNotEquals(0, ccs.size());
}
//invalid ID field: 0Q0M987654AcTg
static testMethod void canLoadAQuoteById() {
Quote q = [SELECT Id from Quote where Id = '0Q0M987654AcTg'];
System.assertNotEquals(null, q);
}
}
I can see that on the 4th test, I am doing something incorrect by trying to use a string as an Id, but I cannot for the life of me firgure out my the third test returns no data. The same is true when I run this test against any built in object type and I know there is data there.
Also, does [SELECT Id from Contact Limit 10]
evaluate to a concrete type? For example could I pass that block of code around to other functions, i.e., doSomething(id, [select Id from Account])
?
Thanks, Joe