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
Mike 317Mike 317 

Testing APEX that sorts a list

Hey All, 
I am working with a 3rd party and they have a VFP with a list that has sortable columns. The test class has test methods without system asserts. On the one hard, this makes sense because what would you actually assert? But on the other hand, this simply calls the method. It doesn't actually validate anything. Code snipet is below. 
	static void test_SortByAccount() {
		RecordReturnsCtrl ctrl = new RecordReturnsCtrl();
		ctrl.columnName = 'Account';
		ctrl.ascendingSort = false;

Is this ok? My gut wants a system assert that checks the results against what is expected. But i'm not sure if i'm just asking for too much. Thanks. 

Best Answer chosen by Mike 317
Hi Mike,

You can add two or three dummy values in the list which you want to sort. Then call sortRecords() method and use assert to check if this function returns the sorted list or not.Thanks