What if your code could test itself every time you save it?
Why Running unit tests in pipeline in Jenkins? - Purpose & Use Cases
Imagine you write code and then manually run tests on your computer before sharing it with your team.
You have to remember to run all tests every time, and sometimes you forget or miss some.
Manually running tests is slow and easy to forget.
It causes bugs to sneak into the shared code because tests were skipped or done incorrectly.
This wastes time fixing problems later.
Running unit tests automatically in a pipeline means tests run every time code changes.
This catches errors early and saves time by stopping bad code from moving forward.
git push origin main
# Then remember to run tests manuallypipeline {
agent any
stages {
stage('Test') {
steps {
sh 'run-unit-tests.sh'
}
}
}
}It makes sure your code is always tested and safe before sharing with others.
A developer pushes code to GitHub, and Jenkins automatically runs all unit tests before merging to the main project.
Manual testing is slow and error-prone.
Automated tests in pipelines catch bugs early.
This keeps code quality high and saves time.