Skip to content

Latest commit

 

History

History
83 lines (61 loc) · 1.94 KB

tests.md

File metadata and controls

83 lines (61 loc) · 1.94 KB

Continuous Testing

This section is dedicated to automated testing and here are your learning objectives,

  • You are going to begin by analysing code coverage with Jococo
  • Learn how to improve the code coverage
  • Setup sonarqube to automatically scan your repository
  • Create a project gating system to automatically decide whether the code is safe to deploy
  • Add integration and acceptance tests with docker compose and finally, incorporate all of these into the Jenkins pipeline

Code coverage with Jacoco

STEPS:

  • Fork this repo: https://github.com/lfs261/maven-examples
  • Add a maven job to run test on it
  • From post build action, publish Jacoco reports
  • Merge ut1, and ut2 branches into master and run the jobs again

Adding Static Code Analysis with Sonarqube

Steps:

Sonarqube stage code snippet for Jenkinsfile [options for the classroom course]

stage('Sonarqube') {
    agent any
    when{
      branch 'master'
    }
    environment{
      sonarpath = tool 'SonarScanner'
    }
    steps {
        echo 'Running Sonarqube Analysis..'
          withSonarQubeEnv('sonar') {
            sh "${sonarpath}/bin/sonar-scanner -Dproject.settings=sonar-project.properties"
          }
    }
}

Adding Integration Tests

STEPS:

  • vote/integration_test.sh
  • run as part of vote pipeline
stage('vote integration'){
    agent any
    when{
      changeset "**/vote/**"
      branch 'master'
    }
    steps{
      echo 'Running Integration Tests on vote app'
      dir('vote'){
        sh 'integration_test.sh'
      }
    }
}

Adding e2e tests

  • ./e2e.sh
  • run as independent job