M

Manisha Agrawal • 9.34K Points
Tutor III

Q. Can we run Junits as a part of Jenkins job?

  • (A) False
  • (B) True
  • (C) ---
  • (D) ---
  • Correct Answer - Option(B)
  • Views: 333
  • Filed under category JAVA

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

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.


Question analytics