🧠 Learning Objectives:
By the end of this lesson, learners will:
- Understand the importance of version control in automation projects
- Install and configure Git locally
- Create and link a GitHub repository to their framework
- Learn basic Git commands for daily use
- Understand best practices for collaborative test automation with Git
📌 1. Why Use Version Control in Test Automation?
Without Git | With Git |
---|---|
Manual file backups | Version history of every test case |
No way to collaborate | Multiple testers can work in parallel |
No rollback on failures | Easily revert changes or bugs |
Risk of overwriting files | Git tracks and resolves merge conflicts |
Difficult CI/CD integration | Seamless with GitHub Actions, Jenkins |
In test automation, especially when working with teams or CI/CD, Git isn’t optional — it’s essential.
🧰 2. Install Git (if not already installed)
🔹 Download Git:
- Visit https://git-scm.com and download for your OS (Windows/macOS/Linux)
🔹 Verify Installation:
git --version
Expected Output:
git version 2.x.x
👤 3. Configure Git Locally
Set your name and email to associate with your commits:
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
Optional: enable colored output and default editor
git config --global color.ui auto
git config --global core.editor "code --wait" # if using VS Code
🗂️ 4. Initialize Git in Your Automation Project
Let’s assume you’ve created your framework folder:
cd ~/projects/salesforce-karate-framework
git init
This creates a hidden .git
folder that starts tracking version history.
Create a .gitignore
file to avoid committing IDE or test output files:
# .gitignore
.idea/
target/
*.log
*.class
.DS_Store
.env
☁️ 5. Create a GitHub Repository
🔹 Steps:
- Go to https://github.com
- Click New Repository
- Name it:
salesforce-karate-framework
- Set visibility: Public or Private
- Don’t initialize with README or
.gitignore
(we already have them)
🔗 6. Connect Local Project to GitHub
In your terminal:
git remote add origin https://github.com/yourusername/salesforce-karate-framework.git
git add .
git commit -m "Initial commit: setup project structure"
git branch -M main
git push -u origin main
🎉 Your project is now under version control and connected to GitHub.
🧪 7. Daily Git Commands for Test Automation Projects
Command | What It Does |
---|---|
git status | Shows current changes |
git add . | Stages all changes |
git commit -m "message" | Saves a snapshot with a message |
git push | Sends commits to GitHub |
git pull | Updates local project from GitHub |
git log | Shows commit history |
git checkout -b new-test | Creates a new branch for a test case |
🌱 8. Best Practices for Automation Projects
- 💡 One branch = one feature or test case
- ✅ Write clear commit messages (e.g.,
add login.feature for Salesforce UI
) - 🔁 Pull before you push to avoid merge issues
- 🧪 Use Git to track test data, config files, and metadata scripts
- 🛠️ Integrate with GitHub Actions (later lessons) to run tests on push/merge
🎓 Learner Exercise:
✅ Create a GitHub repository and push your current automation project
📸 Take a screenshot of your repo andgit log
output
📌 Recap:
Task | Status |
---|---|
Git installed | ✅ |
Configured name/email | ✅ |
Project tracked with Git | ✅ |
Pushed to GitHub | ✅ |