0
0
Gitdevops~20 mins

Automated testing on push in Git - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Automated Testing Pro
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this Git hook command?
You have a pre-push Git hook script that runs tests before pushing. The script contains:
#!/bin/sh
npm test

If the tests fail, what will be the output of git push?
Git
#!/bin/sh
npm test
APush is aborted and error messages from tests are shown.
BPush succeeds regardless of test results.
CGit shows a warning but pushes anyway.
DPush is delayed until tests pass manually.
Attempts:
2 left
💡 Hint
Git hooks can stop push if the script exits with an error.
🧠 Conceptual
intermediate
1:30remaining
Why use automated tests on push in Git workflows?
Which of these is the main reason to run automated tests on every push?
ATo ensure code quality and catch errors early before integration.
BTo slow down the development process intentionally.
CTo avoid writing tests locally by developers.
DTo automatically merge branches without review.
Attempts:
2 left
💡 Hint
Think about preventing broken code from entering shared branches.
Configuration
advanced
1:30remaining
Which Git hook file should you create to run tests automatically before pushing?
You want to run a test script automatically every time you push code. Which file should you create or edit inside the .git/hooks directory?
Apost-commit
Bpost-push
Cpre-push
Dpre-commit
Attempts:
2 left
💡 Hint
The hook runs right before pushing to remote.
Troubleshoot
advanced
2:00remaining
Why does my pre-push hook not stop the push even if tests fail?
You wrote a pre-push hook script to run tests, but even when tests fail, the push still succeeds. What is the most likely cause?
AThe remote repository ignores hooks.
BThe hook script does not exit with a non-zero status on test failure.
CGit does not support pre-push hooks.
DTests are not run because the script is named incorrectly.
Attempts:
2 left
💡 Hint
Git stops push only if the hook exits with an error code.
🔀 Workflow
expert
2:30remaining
Order the steps in a Git workflow with automated testing on push
Arrange these steps in the correct order when using automated tests triggered by a Git pre-push hook.
A1,2,4,3
B2,1,3,4
C1,3,2,4
D1,2,3,4
Attempts:
2 left
💡 Hint
Think about the natural flow from coding to pushing with tests in between.