Skip to content

Commit 1105ee3

Browse files
authored
Merge pull request #1244 from gordon-cs/s25-fix-test-automation
update readme file for test automation
2 parents 69c65fc + 547b33d commit 1105ee3

File tree

2 files changed

+44
-18
lines changed

2 files changed

+44
-18
lines changed

Gordon360.Tests/ReadMe.md

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -676,32 +676,51 @@ After committing and pushing this file, GitHub will automatically run your tests
676676
677677
You can add a **pre-commit Git hook** that runs your unit tests before any commit is finalized.
678678
679-
#### 🛠 Setup Instructions (PowerShell for Windows)
679+
#### 🛠 Setup Pre-commit Hook (Manual — Recommended)
680680
681-
```powershell
682-
# 1. Navigate to your repo root
683-
cd path\to\your\repo # Replace with your actual repo path
684681
685-
//if you are on virtual machine:
686-
cd C:\Users\User.Name(replace with your username)\Source\Repos\gordon-cs\gordon-360-api>
682+
1️⃣ Navigate to your repo root
683+
```bash
684+
685+
cd path/to/your/repo
686+
687+
Example (on Windows Virtual Machine):
688+
689+
C:\Users\Your__UserName\Source\Repos\gordon-cs\gordon-360-api
690+
```
691+
692+
2️⃣ Open .git/hooks/pre-commit
693+
694+
If the file does not exist, create a new file named pre-commit in .git/hooks/.
695+
687696

688-
# 2. Create the pre-commit hook file
689-
New-Item -ItemType File -Path .git/hooks/pre-commit
690697

691-
# 3. Add script to run tests before each commit
692-
@"
698+
3️⃣ Copy and paste the following script into pre-commit file:
699+
```bash
700+
693701
#!/bin/sh
694-
echo "Running unit tests before commit..."
702+
echo "Running build before commit..."
703+
704+
dotnet build --no-restore --verbosity quiet
705+
BUILD_EXIT_CODE=$?
706+
707+
if [ $BUILD_EXIT_CODE -ne 0 ]; then
708+
echo " Build failed. Commit aborted."
709+
exit 1
710+
fi
695711

696-
dotnet test --no-build --verbosity quiet
712+
echo "Running tests before commit..."
697713

698-
if [ $? -ne 0 ]; then
699-
echo "Unit tests failed. Commit aborted."
714+
dotnet test gordon360.Tests/gordon360.Tests.csproj --no-build --verbosity quiet
715+
TEST_EXIT_CODE=$?
716+
717+
if [ $TEST_EXIT_CODE -ne 0 ]; then
718+
echo " Tests failed. Commit aborted."
700719
exit 1
701720
else
702-
echo "All tests passed. Proceeding with commit."
721+
echo " Build and tests passed. Proceeding with commit."
703722
fi
704-
"@ | Set-Content .git/hooks/pre-commit
723+
705724
```
706725

707726
> ⚠️ This only runs locally on your machine. Others won't get it unless shared via tools like Husky.

Gordon360/Documentation/Gordon360.xml

Lines changed: 9 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)