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
Michael MMichael M 

Help with test class for controller

Hello, I need help writing a test class. Here is my class (I am using it as a controller for an aura component).

public class getListViews {
@AuraEnabled
public static List<ListView> getListViews() {
    List<ListView> listviews =
        [SELECT Id, Name FROM ListView WHERE SobjectType = 'Discharge__c' and Name ='All New Discharges'];
    // Perform isAccessible() check here
    if (Schema.sObjectType.Discharge__c.isAccessible()){
    return listviews;
    }
    return listviews;
}

}

Can someone please assist in writing test class.
Best Answer chosen by Michael M
Dev-FoxDev-Fox
Hi Michael,
Try this:
@isTest
private class getListViewsTest
{
    @isTest
    static void TestgetListViews()
    {
        getListViews.getListViews();
    }
}

All Answers

Dev-FoxDev-Fox
Hi Michael,
Try this:
@isTest
private class getListViewsTest
{
    @isTest
    static void TestgetListViews()
    {
        getListViews.getListViews();
    }
}
This was selected as the best answer
Michael MMichael M
Great- thank you.