回答編集履歴
3
修正
test
CHANGED
@@ -50,7 +50,7 @@
|
|
50
50
|
|
51
51
|
public static List<Contact> searchForContacts(String lastName, String postNum){
|
52
52
|
|
53
|
-
List<Contact> Contacts = [Select Id, Name from Contact where LastName = :lastname AND MailingPostalCode = :postNum ];
|
53
|
+
List<Contact> Contacts = [Select Id, Name from Contact where LastName = :lastname AND MailingPostalCode = :postNum ORDER BY Id LIMIT 1];
|
54
54
|
|
55
55
|
return Contacts;
|
56
56
|
|
2
再調整
test
CHANGED
@@ -48,9 +48,9 @@
|
|
48
48
|
|
49
49
|
public class ContactSearch {
|
50
50
|
|
51
|
-
public static List<Contact> searchForContact(String lastName, String postNum){
|
51
|
+
public static List<Contact> searchForContacts(String lastName, String postNum){
|
52
52
|
|
53
|
-
List<Contact> Contacts = [Select I
|
53
|
+
List<Contact> Contacts = [Select Id, Name from Contact where LastName = :lastname AND MailingPostalCode = :postNum ];
|
54
54
|
|
55
55
|
return Contacts;
|
56
56
|
|
@@ -60,6 +60,26 @@
|
|
60
60
|
|
61
61
|
```
|
62
62
|
|
63
|
-
|
63
|
+
テストクラス
|
64
64
|
|
65
|
+
```APEX
|
66
|
+
|
67
|
+
@isTest
|
68
|
+
|
69
|
+
public class ContactSearchTest {
|
70
|
+
|
71
|
+
@isTest static void searchForContacts() {
|
72
|
+
|
73
|
+
Test.startTest();
|
74
|
+
|
75
|
+
List<Contact> Contacts = ContactSearch.searchForContacts('Rogers', '27215');
|
76
|
+
|
77
|
+
System.assertEquals(Contacts.size() != 1, true);
|
78
|
+
|
65
|
-
|
79
|
+
Test.stopTest();
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
}
|
84
|
+
|
85
|
+
```
|
1
修正
test
CHANGED
@@ -50,9 +50,9 @@
|
|
50
50
|
|
51
51
|
public static List<Contact> searchForContact(String lastName, String postNum){
|
52
52
|
|
53
|
-
|
53
|
+
List<Contact> Contacts = [Select ID,Name from Contact where LastName = :lastname AND MailingPostalCode = :postNum ];
|
54
54
|
|
55
|
-
return
|
55
|
+
return Contacts;
|
56
56
|
|
57
57
|
}
|
58
58
|
|