Units will not attack until the target is in range and sight. Otherwise, they will keep moving to the attack target or will attack another target.