+ Start a Discussion

Contacts Test Class Confusion

I'm attempting to build a test class for a connection between two contacts using the contact connector.  The idea is using VF to show the contacts on both sides of the contact for a many to many contact relationship.

Problem is I'm not sure of the process for the test case.   I assume the steps are:

-Create a instance of the object between the two contacts
-Create a contact and "related contact" and populate it
-The test to see if I can see the Contact2 ID from Contact1.  

Works fine in Sandbox but not sure how to write up the test as sometimes Eclipse give me the error "Error in code" but without specifics, but can't get it to pass 75%. 

Any advice would be super helpful.  

Some of this code was taken from the NPSF chat.

public class Contact_Connection {
   private final Contact cont;
    // The extension constructor initializes the private member
    // variable acct by using the getRecord method from the standard
    // controller.
    public Contact_Connection(ApexPages.StandardController stdController) {
        this.cont = (Contact)stdController.getRecord();

public String getName(){
       return 'Inbound and Outbound Connections';
      public list <SFDC_Contact_Connector__c> getConnections() {
        List <SFDC_Contact_Connector__c> connections;
        connections = [select id, name, Contact__r.name,
  Related_Contact__r.name, Relationship__c, Description__c,
  Related_Organization__r.name, Related_Organization_Role__c from
  SFDC_Contact_Connector__c where Contact__c
  = :System.currentPageReference().getParameters().get('id') OR
  Related_Contact__c = :System.currentPageReference().getParameters().get('id')];
        return connections;


<apex:page standardController="Contact" extensions="Contact_Connection">
 <apex:pageBlock title="This contact has made the following connections" helpTitle="" helpUrl="">
  <apex:pageBlockTable value="{!connections}" var="connection"
    id="cList" width="100%">
   <apex:column >
     <apex:facet name="header">Contact</apex:facet>
     <apex:outputLink value="/{!if(LEFT(connection.Contact__c,15) ==
            connection.Related_Contact__c, connection.Related_Organization__c),


Message Edited by timrnichols on 09-26-2008 03:30 PM

 view this post and see if it helps with your case:



 Hi Tim,

 Check this post out It will help you come over the problem.


 Good luck!