+ Start a Discussion

Type is not visible error message on Visualforce page

I am getting the following error on a custom Visualforce page:

Type is not visible: test


Vforce Page:

<apex:page controller="EditCases" tabstyle="Case"> <apex:sectionHeader title="Edit Cases" subtitle="Bug Meeting Mass Update" /> <apex:form > <apex:pageBlock mode="edit" title="Mass Update Cases"> <p><apex:outputText value="{!headerMessage}" /></p> <h3>Report Criteria: </h3> <p></p> <table style="width: 100%"> <tr> <td rowspan="3" width="50px" height="50px"><img src="https://ssl.salesforce.com/servlet/servlet.ImageServer?id=01500000000crMo&oid=00D00000000hZTB&lastMod=1235399976000"></img></td> <td>Sub Status contains <i>bug</i> </td> </tr> <tr> <td>ETA is <i>NULL</i></td> </tr> <tr> <td>Status is <i>Pending</i> or <i>Suspended</i></td> </tr> </table> <br /> <apex:pageblockSection id="Cases" columns="1" title="Bug Meeting Cases" rendered="{!canEdit}"> <apex:pageblocktable align="center" value="{!Cases}" var="Case" title="Cases" width="100%"> <apex:column headerValue="Case Number" width="10%"><apex:outputLink value="/{!Case.ID}">{!Case.CaseNumber}</apex:outputlink></apex:column> <apex:column headerValue="Account" width="15%"><apex:outputLink value="/{!Case.Account.ID}">{!Case.Account.Name}</apex:outputlink></apex:column> <apex:column headerValue="Bug ID" width="50%"><apex:inputField value="{!Case.Bug_ID__c}" /></apex:column> <apex:column headerValue="Subject" width="50%"><apex:inputField value="{!Case.Subject}"/></apex:column> <apex:column headerValue="Bug Description" width="50%"><apex:inputField value="{!Case.Bug_Description__c}" /></apex:column> <apex:column headerValue="Summary" width="50%"><apex:inputField value="{!Case.Bug_Meeting_Summary__c}" /></apex:column> <apex:column headerValue="ETA" width="50%"><apex:inputField value="{!Case.ETA_version__c}" /></apex:column> <apex:column headerValue="Assigned To" width="50%"><apex:inputField value="{!Case.Bug_Assigned__c}" /></apex:column> <apex:column headerValue="Status" width="15%"><apex:inputField value="{!Case.Status}"/></apex:column> <apex:column headerValue="Sub Status" width="15%"><apex:inputField value="{!Case.Sub_Condition__c}"/></apex:column> </apex:pageblockTable> </apex:pageblockSection> <p/> <apex:pageBlockButtons > <apex:commandButton action="{!save}" value="Save Cases" rendered="{!canEdit}" /> <apex:commandButton action="{!cancel}" value="Cancel" /> </apex:pageblockButtons> </apex:pageBlock> </apex:form> </apex:page>



Apex Class+Test:

public class EditCases { List<Case> cases; String headerMessage; Boolean canEdit = true; public EditCases() { cases = getcases();+ headerMessage = getHeaderMessage(); canEdit = getCanEdit(); } public List<Case> getCases() { if (cases == null) { cases = [ select Id, CaseNumber, Priority, Status, Subject, Case.Account.ID,Case.Account.Name,Case.Bug_ID__c,Case.Bug_Description__c,Case.Bug_Meeting_Summary__c,Case.ETA_version__c, CreatedDate,Sub_Condition__c, Bug_Assigned__c from Case where sub_condition__C like '%Bug%' and ETA_version__C = null and (Status = 'Pending' or Status = 'Suspended') order by CaseNumber]; return cases; } else { return cases; } } public String getHeaderMessage() { String message = ''; if (cases.size() == 0) { message = 'There are no cases to edit.'; canEdit = false; } else { canEdit = true; } return message; } public Boolean getCanEdit() { return canEdit; } // Action that is executed if Save button is clicked public PageReference save() { // Return to Cases tab page after editing PageReference returnPage = new PageReference('/500/o'); // Save all changes update cases; return returnPage; } // Action that is executed if Cancel button is clicked. public PageReference cancel() { // Return to Cases tab page after editing PageReference returnPage = new PageReference('/500/o'); return returnPage; } public static testMethod void tesEditCases() { // Create the necessary records to test automatic order creation // Create a case // This assumes that the pick list values used exist for // - Priority (High) // - Status (New) // - Origin (Phone) Case testCase = new Case( Priority = 'High', Subject = 'Test Subject', Status = 'Pending', LPTicket__c = 'LTK12345X', sub_condition__C = 'Bug Meeting', // ETA_version__C = '8.4', // Bug_ID__C = '1234', Origin = 'Phone'); insert testCase; //************************** // Test EditCases controller //************************** PageReference pageRef = Page.EditCases; Test.setCurrentPage(pageRef); // Create an instance of the controller EditCases editCasesController = new EditCases(); // Get the list of cases from the controller List<Case> casesToEdit = editCasesController.getCases(); // Verify that there is at least one case to edit system.assertEquals(casesToEdit.size() > 0, true); // Retrieve the header message String editCasesMessage = editCasesController.getHeaderMessage(); // Verify that the header message is blank system.assertEquals(editCasesMessage, ''); // Check the Cancel action String canceleditCasesPage = editCasesController.cancel().getUrl(); // Check the save action String editCasesPage = editCasesController.save().getUrl(); } }


Nothing has changed in my environment or in my apex class and Vforce pages. Any help or suggestions welcome.


I spent about two days to fix the similar error. May be my experience will help somebody.


In my case many Apex classes finished long time ago suddenly began to fail the tests. The errors in IDE were with the same text "Type is not visible: test" and were located at the headers of some methods, not at certain lines. I suspect even new SFDC release, which took place some days before.


The reason turned out simple but rather hard-to-detect. Some days ago I created new class with unoriginal name Test. And in wrong methods there are lines like





I believe the situation got obvious. I removed my class with name Test and the problem disappeared.



I suppose it's not very good behavior of Apex itself in this situtation (which is rather common on my mind). First, why Apex let create class with the name of an existing system class? The second, it would be much better lo locate error directly at line like in my example above, not at header of a class. And third, the error message isn't very verbose. Yes, I understood it but only after having found the error.


I suspect that class `Test` was transfered into class `System`. Use System.Test.method(). It works.