UnitTestCase : Each time I have to set user in session, if my function uses JFactory::getUser($id)

When I write a unit test case for a function, which has the code JFactory::getUser(); inside, then I need to set user in session. Otherwise session does not contain anything, and return NULL on first line of function. If $instance is null then it gets an error for "Accessing undefined property on on non-object" ($instance->id ).

So an extra check it put to check if $instance is instance of JUSer, before accessing its id.