java
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
import java.util.List;
public class UserServiceTest {
@Test
public void testSearchUserByTags() {
// 模拟标签列表
List<String> tagNameList = List.of("tag1", "tag2", "tag3");
// 调用方法
List<User> userList = userService.searchUserByTags(tagNameList);
// 断言列表不为null
assertNotNull(userList, "userList should not be null");
// 断言列表不为空
assertFalse(userList.isEmpty(), "userList should not be empty");
// 可选:打印日志
System.out.println("Search result: " + userList);
}
}
-
assertNotNull:确保userList不为null。 -
assertFalse:确保userList不为空。