Use the User.permissions property instead of groups.
Create user groups in test setup.