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
Mikhail Nitko 6Mikhail Nitko 6 

I am new. How do I write a test class for this?

Hi folks,

I'm new to writing test classes and have put together a simple, working apex class but am not sure how to test it.

I am currently working through the Trailhead and am still confused.

How would I write a test for the following?:
 
public class studentQueueUMB {

List<Case> walkin;


public List<Case> getWalkin(){
walkin =  [SELECT Display_Name__c, Display_Screen_Suffix__c FROM Case WHERE Origin = 'Walk-in' and Status != 'Closed' and Remove_From_Screen__c = FALSE ORDER BY CreatedDate ASC NULLS FIRST LIMIT 10];

return walkin;
}
}
Thank you!
Mikhail Nitko 6Mikhail Nitko 6
I did it! .. I googled and googled and tried a dozen things but hours later I finally have it!

Check out my first, original test class:
@isTest
private class TestStudentQueue {

static testmethod void verifyQueue(){

case a = new Case(Display_Screen_Suffix__c='test',Origin='Walk-in',Status='Closed');

insert a;

studentQueueUMB ats = new studentQueueUMB();
ats.getWalkin();
}
}

Aint she a beauty?