Q. Can we run Junits as a part of Jenkins job?
β
Correct Answer: (B)
True
Explanation:
Yes, JUnit tests can be run as part of a Jenkins job. Jenkins supports JUnit test execution and reporting through various plugins like:
- JUnit Plugin β Used to display test reports.
- Maven / Gradle Integration β Runs JUnit tests as part of the build process.
- Pipeline scripts β JUnit tests can be executed in scripted and declarative pipelines using junit step.
Example: Running JUnit in Jenkins Pipeline
pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'mvn clean test' // Runs JUnit tests
}
}
stage('Report') {
steps {
junit '**/target/surefire-reports/*.xml' // Publishes JUnit reports
}
}
}
}
Thus, the correct answer is: (B) True β