Search code examples
jenkinsgroovycontinuous-integration

Add tests on Groovy scripts used in Jenkins


I have a bunch of groovy scripts that is used by Jenkins. I would like add some tests to these groovy scripts so that any update to groovy scripts i can add test them before merging.

I would like to know what options do we have to write test cases to Groovy scripts. Also how do i execute these tests preferably in ci (gitlab ci) before merging them

Any pointers would be helpful.


Solution

  • You can unit test the complete Pipeline using something like Jenkins Pipeline Unit. If you are only interested in Groovy code, you can consider using Groovy unit testing framework.