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

Backend test coverage report #1616

Merged
merged 4 commits into from
Oct 15, 2024
Merged

Backend test coverage report #1616

merged 4 commits into from
Oct 15, 2024

Conversation

seluianova
Copy link
Contributor

@seluianova seluianova commented Sep 3, 2024

Short description

I suggest applying the kover plugin to be able to build test coverage reports in the backend.
It allows you to see the test coverage per line of code like this:
image

Side effects

This creates a bit of clutter in the circle ci artifacts.
Alternatives to the clutter would be:

  • attach all files as an archive, but it would require an additional download/unzip action to view the report
  • connect additional tools to upload and view reports there (for example, CMS uses Code Climate: https://codeclimate.com/github/digitalfabrik/integreat-cms/code)
  • do not generate a report in ci, use only locally

Testing

  • build the report locally:
    ./gradlew koverHtmlReport
    or
  • view in circleci:
    image

Resolved issues

n/a

Additional info

Our current test coverage is 31.4741% (per line)

@seluianova seluianova force-pushed the backend-test-coverage-report branch 4 times, most recently from ebe08e5 to 69bd989 Compare September 5, 2024 11:36
@seluianova seluianova marked this pull request as ready for review September 5, 2024 12:30
Copy link
Member

@ztefanie ztefanie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for bringing up this topic and creating a solution.

The tests did not work for me locally, as there where failing tests. I am on current branch and ran the tests with the ./gradlew koverLog koverHtmlReport command. Are there any additional steps needed before?

> Task :test

app.ehrenamtskarte.backend.auth.service.AuthorizerTest > classMethod FAILED
    java.lang.IllegalStateException at DockerClientProviderStrategy.java:277
Java HotSpot(TM) 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended

app.ehrenamtskarte.backend.cards.CreateCardFromSelfServiceTest > classMethod FAILED
    java.lang.IllegalStateException at DockerClientProviderStrategy.java:232

app.ehrenamtskarte.backend.userdata.UserImportTest > classMethod FAILED
    java.lang.IllegalStateException at DockerClientProviderStrategy.java:232

45 tests completed, 3 failed

> Task :test FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':test'.
> There were failing tests. See the report at: file:///home/steffi/Dokumente/entitlementcard/backend/build/reports/tests/test/index.html

some other toughts:

  1. we have this codescene integreation ticket, that is releated: Add codescene PR integreation #1356
  2. i do not really mind the cluttering in the artifacts tab, as in the check backend step there are no other artifacts we want to find
  3. i would love to get an automatic message to the PR getting information on how many of the changed lines are covered by tests, or how the changes of the PR increased/decreased the test coverage. With only the changes you suggested, i think we will rarely look at this.

@seluianova
Copy link
Contributor Author

seluianova commented Sep 10, 2024

The tests did not work for me locally, as there where failing tests. I am on current branch and ran the tests with the ./gradlew koverLog koverHtmlReport command. Are there any additional steps needed before?

@ztefanie I have an assumption that the tests are not working for you locally on the main branch either. Could you please check? ./gradlew test
It looks like an issue with the database container.
If so, this instruction might help:
https://github.com/digitalfabrik/entitlementcard/blob/main/docs/testcontainers-troubleshooting.md

Copy link
Contributor

@f1sh1918 f1sh1918 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works as expected on macos, nice!

@seluianova
Copy link
Contributor Author

seluianova commented Sep 10, 2024

With only the changes you suggested, i think we will rarely look at this.

@ztefanie actually I do look into the report when I add tests. maybe then I remove it from CI for now until we implement a nice representation with an automatic message etc using codescene?

@ztefanie
Copy link
Member

With only the changes you suggested, i think we will rarely look at this.

@ztefanie actually I do look into the report when I add tests. maybe then I remove it from CI for now until we implement a nice representation with an automatic message etc using codescene?

As you already implemented it, I would prefer not to remove it. Maybe an issue with a follow up task of bringing the results of the testing back to github is enough?

@f1sh1918
Copy link
Contributor

f1sh1918 commented Oct 14, 2024

@ztefanie @seluianova
Whats about this pr here? :)
I think if a follow up issue will be created this pr can be approved and merged?!

@seluianova
Copy link
Contributor Author

I have created a follow-up task #1682

# Conflicts:
#	backend/src/main/kotlin/app/ehrenamtskarte/backend/cards/Argon2IdHasher.kt
#	docs/CreateKoblenzHash.md
@seluianova seluianova merged commit 3ce27fe into main Oct 15, 2024
1 check passed
@seluianova seluianova deleted the backend-test-coverage-report branch October 15, 2024 13:18
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

Successfully merging this pull request may close these issues.

3 participants