when(userMapper.insert(userEntity)).thenReturn(1);

改成: when(userMapper.insert(any(UserEntity.class))).thenReturn(1);

Originally posted by @yuxiaobin in https://github.com/baomidou/mybatis-plus/issues/2781#issuecomment-666199747