# How to sonar testcoverage ## Go 1) add
`- run: go mod download`
`- run: go generate`
`- name: Unit Tests with Coverage`
`run: go test -coverprofile=coverage.out ./...`
to `sonarqube-build.yml` --- ## Spring Boot 1) add `run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=chickenshock-backend -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml` to `sonarqube-build.yml` 1) add
``
    `org.jacoco`
    `jacoco-maven-plugin`
    `0.8.7`
    ``
        ``
        ``
            `prepare-agent`
        `
`
        `
`
        ``
        `report`
        `prepare-package`
        ``
                `report`
        `
`
        `
`
        ``
        `generate-code-coverage-report`
        `test`
        ``
            `report`
        `
`
        `
`
    `
`
`
`
to `pom.xml` 1) to test database add
# Service containers to run with runner-job
    services:
      # Label used to access the service container
      postgres:
        # Docker Hub image
        image: postgres
        # Provide the password for postgres
        env:
          POSTGRES_PASSWORD: [DB_PW_HERE]
        # Set health checks to wait until postgres has started
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
        ports:
          # Maps tcp port 5432 on service container to the host
          - 5432:5432 
between `runs-on: self-hosted` and `steps` to `sonarqube-build.yml` ## Vue 1) add
`- run: npm ci`
`- name: Unit Tests with Coverage`
`run: npm run test:unit -- --coverage --testResultsProcessor=jest-sonar-reporter`
to `sonarqube-build.yml` 1) create `jest.config.js` in top directory 1) add
`module.exports = {`
    `preset: '@vue/cli-plugin-unit-jest/presets/typescript-and-babel',`
`};`
to `jest.config.js` 1) execute `vue add unit-jest` 1) type `y` 1) execute `npm install jest jest-sonar-reporter ts-jest @vue/cli-service @vue/cli-plugin-typescript @types/jest --save-dev` 1) file folder `/tests/unit/example.spec.ts` 1) add
`describe('Example', () => {`
    `test('true is true', () => {`
        `expect(true).toBeTruthy();`
    `});`
`});`
to `/tests/unit/example.spec.ts`