function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ranadheer chRanadheer ch 

i created a test class but am getting the following error

My class

public with sharing class AccountContactRoles {
    private final Contact acr;
    public AccountContactRoles(ApexPages.StandardController controller){
        this.acr = (Contact)controller.getRecord();
    public List<AccountContactRole> acrs {
        get {
            if (acrs == null) {
                acrs = [Select Id, AccountId, ContactId, Role, IsPrimary From AccountContactRole
                    Where ContactId=:acr.Id];               
            return acrs;
        private set;

my Test class

private class TestAccountcontactroleClass{
    private static void testClass()
    //Standard controller of Accountcontactrole
    //Create a new instance of Accountcontactrole
    Account acc = new Account(Name = 'Test Account');
    insert acc;
    Contact con = new Contact(LastName = 'Test Last Name', AccountId = acc.Id);
    insert con;
    AccountContactRole acr1 = new AccountContactRole();
                acr1.AccountId = acc.Id;
                acr1.ContactId = con.Id;
                acr1.Role = 'Test 1';
            insert acr1;
    //Insert the object virtually

    //Create a new instance of standard controller
    ApexPages.StandardController sc = new ApexPages.standardController(con);

    AccountContactRoles controller = new AccountContactRoles(sc);   

And am getting the following error.

Error: Compile Error: Dependent class is invalid and needs recompilation:
AccountContactRoles: line 11, column 17: Illegal assignment from LIST<AccountContactRole> to LIST<AccountContactRole> at line 25 column 42.

i dont understand why am getting me out ...thanks
Please change your class Name 'AccountContactRole' to some other name.That might cause the issue.