πŸ“Š JAVA
Q. Can we run Junits as a part of Jenkins job?
  • (A) False
  • (B) True
  • (C) ---
  • (D) ---
πŸ’¬ Discuss
βœ… 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 βœ…

Explanation by: Mr. Dubey

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 βœ…

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
443
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Manisha Agrawal
Publisher
πŸ“ˆ
98%
Success Rate