Populating an EnumProperty using a Function
You can use UILayout.prop_search to assign a group to a string.

import bpy

bpy.types.Object.test = bpy.props.StringProperty(name="Group")

def draw(self, context):
    self.layout.prop_search(context.object, "test", bpy.data, "groups")

bpy.types.OBJECT_PT_relations.append(draw)


If you use an EnumProperty blender stores the unique id / number, not the string. So you need a separate StringProperty to keep track of the group, in case the user deletes a group and your enumeration of the groups assigns a different index to the selected group.

def get_items():
    #closure - keep a reference to the list
    items = None
    def func(self, context):
        items = [(group.name, group.name, "") for group in bpy.data.groups]
        return items
    return func

bpy.types.Object.enum_prop = bpy.props.EnumProperty(items=get_items())

def draw_menu_enum(self, context):
    self.layout.prop_menu_enum(context.object, "enum_prop", "Group")

bpy.types.OBJECT_PT_relations.append(draw_menu_enum)