Trying to test a function in a class. The function in the class is the following :
public static boolean clearPosition(Id recId) {
YRec__c rec = [Select Id, Position__c From YRec__c];
rec.Position__c = null;
update rec;
return true;
}
And this is my test function :
public static void checkClearPosition() {
YRec__c obj = new YRec__c();
obj.Position__c = '12843449l49';
insert obj;
Boolean result = clearPosition(obj.Id);
//The result I get is true
System.debug(obj.Position__c); //Prints out the number I set above instead of null
}
Why isn't my object updated? I've inserted it and then in the function I call, the record gets updated but now when I access the field in the function it still shows the initial value.