44 lines
1.4 KiB
Bash
Executable File
44 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Thư mục chứa test
|
|
TEST_DIR="."
|
|
|
|
echo "🚀 Đang quét và tạo Native Integration Tests..."
|
|
|
|
# Tìm tất cả các file kết thúc bằng Test.java nhưng không phải là IT.java
|
|
find "$TEST_DIR" -name "*Test.java" ! -name "*IT.java" | while read -r test_file; do
|
|
|
|
# Kiểm tra xem file có sử dụng RestAssured không
|
|
if grep -q "import static io.restassured.RestAssured" "$test_file" || grep -q "import io.restassured.RestAssured" "$test_file"; then
|
|
|
|
# Lấy tên package
|
|
package_line=$(grep -m 1 "^package " "$test_file")
|
|
|
|
# Lấy tên class gốc
|
|
test_class=$(basename "$test_file" .java)
|
|
|
|
# Tạo tên class IT mới
|
|
it_class="Native${test_class/Test/IT}"
|
|
it_file="$(dirname "$test_file")/${it_class}.java"
|
|
|
|
if [ -f "$it_file" ]; then
|
|
echo "⏭️ Đã tồn tại: $it_class"
|
|
else
|
|
echo "✅ Đang tạo IT cho API Test: $it_class"
|
|
|
|
cat <<EOF > "$it_file"
|
|
$package_line
|
|
|
|
import io.quarkus.test.junit.QuarkusIntegrationTest;
|
|
|
|
@QuarkusIntegrationTest
|
|
public class $it_class extends $test_class {
|
|
// Chạy Native IT cho API Test (Sử dụng RestAssured)
|
|
}
|
|
EOF
|
|
fi
|
|
else
|
|
# Bỏ qua các file dùng @Inject (thường là Service hoặc Unit Test logic)
|
|
echo "📜 Bỏ qua: $(basename "$test_file")"
|
|
fi
|
|
done |