Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Measure test coverage #94

Open
4 tasks
CSchoel opened this issue Jul 15, 2021 · 2 comments
Open
4 tasks

Measure test coverage #94

CSchoel opened this issue Jul 15, 2021 · 2 comments
Assignees

Comments

@CSchoel
Copy link
Contributor

CSchoel commented Jul 15, 2021

  • Generate code coverage reports from your test suite
    • Suggested sources for help: google "java code coverage", or "codecov java"
  • Upload coverage reports manually to a tool like Codecov.io
    • Suggested sources for help: manually browsing through the Codecov.io docs
  • Integrate coverage reports into CI pipeline in GitHub Actions
    • Suggested sources for help: google "codecov github actions", manually browsing through the Codecov.io docs
  • Add a badge to the README that shows the code coverage
@CSchoel
Copy link
Contributor Author

CSchoel commented Aug 2, 2021

As requested, here is your HowTo for setting up codecov:

  • Install the Codecov GitHub App for the MopeSWTP-SS21 organization and grant access only to this repository.
  • Login on Codecov.io with your GitHub account.
  • You should be able to see your project in your dashboard with the text "No data available" in the test coverage column.
    Click on the project and copy the upload token that is displayed.
  • Save the upload token as an encrypted environment variable in the repository:
    • From the repository main page go to Settings -> Secrets -> New repository secret.
    • Enter CODECOV_TOKEN as name and the copied token from the previous (top-level) step as value.
    • Click "Add secret".
  • Enable Jacoco in the Gradle settings:
    • I have already done this in the [feature/sonarQube branch](https://github.com/MopeSWTP-SS21/MopeSWTP/compare/feature/sonarQube, but feel free to also do it yourself on your own feature branch.
      The merge conflicts should not be too much of an issue.
      The optimal strategy would be to cherry-pick my existing commit, but you don't have to do that.
    • If you want to do it manually, you need to add the changes in example 1 and 2 in the Jacoco plugin documentation to your build.gradle.
    • You also need to add the following code to configure the jacocoTestReport task to generate reports in XML format (see the Gradle example repository):
      reports {
          xml.enabled true
          html.enabled false
      }
  • Update the CI script to create and upload test reports:
    • Create test reports with ./gradlew jacocoTestReport

    • Upload test reports with:

      curl -Os https://uploader.codecov.io/latest/linux/codecov 
      chmod +x codecov
      ./codecov -t ${CODECOV_TOKEN}

Resources:

@CSchoel
Copy link
Contributor Author

CSchoel commented Aug 2, 2021

Update: When #116 is merged, you can use the Jacoco Gradle settings that I already implemented for the code coverage reports for SonarQube.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants