Skip to content

nhana123/Codecept_JS_AI_testing

Repository files navigation

🤖 CodeceptJS AI Testing

Dự án kiểm thử tự động E2E sử dụng CodeceptJS + AI (Azure OpenAI / Google Gemini).

✨ Tính Năng

  • ✅ Tích hợp AI để tạo test data động (email, password, phone...)
  • ✅ Phân tích UI tự động và đề xuất test case
  • ✅ Kiểm thử đăng nhập với nhiều kịch bản
  • ✅ Báo cáo đẹp với Allure Report
  • ✅ Hỗ trợ Azure OpenAI và Google Gemini

🚀 Cài Đặt

git clone https://github.com/nhana123/Codecept_JS_AI_testing.git
cd Codecept_JS_AI_testing
npm install

⚙️ Cấu Hình

Tạo file .env:

Azure OpenAI:

AI_PROVIDER=azure
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com
AZURE_OPENAI_KEY=your-api-key
AZURE_OPENAI_DEPLOYMENT=your-deployment-name
AZURE_OPENAI_API_VERSION=2023-05-15

Google Gemini:

AI_PROVIDER=gemini
GEMINI_API_KEY=your-gemini-api-key
GEMINI_MODEL=gemini-pro

� Cấu Trúc

├── codecept.conf.js       # Cấu hình CodeceptJS + AI
├── helpers/AIHelper.js    # AI Helper methods
├── pages/LoginPage.js     # Page Object Model
├── tests/                 # Test cases
│   ├── login_test.js
│   ├── ai_helper_test.js
│   └── gemini_demo_test.js
└── output/                # Test results & reports

🎯 Chạy Test

# Chạy tất cả tests
npx codeceptjs run --plugins allure

# Chạy test cụ thể
npx codeceptjs run tests/login_test.js --plugins allure

# Xem báo cáo
npx allure serve output

💡 Sử Dụng AI Helper

const { I } = inject();

Scenario('Test với AI', async ({ I }) => {
  // Hỏi AI
  const answer = await I.askAI('Test automation là gì?');
  
  // Tạo test data
  const emails = await I.generateTestData('email', 5, false);
  
  // Phân tích UI
  const analysis = await I.analyzeUI();
  
  // Giải thích lỗi
  const help = await I.explainError('Element not found');
});

🔧 AI Helper Methods

  • askAI(question) - Hỏi AI bất kỳ câu hỏi nào
  • generateTestData(type, count, valid) - Tạo test data
  • analyzeUI() - Phân tích giao diện
  • explainError(error) - Giải thích lỗi
  • suggestAssertions(context) - Gợi ý assertions

📖 Chi tiết: AI_USAGE_GUIDE.md

🧪 Test Cases

  • login_test.js - Kiểm thử đăng nhập cơ bản
  • filless_login_test.js - Kiểm thử validation email
  • ai_helper_test.js - Demo AI Helper
  • gemini_demo_test.js - Demo Gemini AI
  • ai_ridervolt_test.js - Test tích hợp RiderVolt

📚 Tài Liệu

📝 License

MIT License


Happy Testing! 🚀

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published