Skip to content

Switch from truth to assertj and add junit launcher#310

Merged
pkwarren merged 2 commits intomainfrom
pkw/truth-to-assertj
Jun 2, 2025
Merged

Switch from truth to assertj and add junit launcher#310
pkwarren merged 2 commits intomainfrom
pkw/truth-to-assertj

Conversation

@pkwarren
Copy link
Member

@pkwarren pkwarren commented Jun 2, 2025

Update from truth to assertj (truth pulls in a JUnit 4 dependency) and use the JUnit 5 BOM and specify the runtime launcher dependency. This should unblock migrating to newer versions of JUnit 5.

Update from truth to assertj (truth pulls in a JUnit 4 dependency) and
use the JUnit 5 BOM and specify the runtime launcher dependency. This
should unblock migrating to newer versions of JUnit 5.
# test
androidGradlePlugin = "7.3.1"
assertj = "3.27.2"
guava = "33.4.8-jre"
Copy link
Member Author

Choose a reason for hiding this comment

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

One test requires Guava and it was pulled in before via truth as a transitive dep.

@pkwarren
Copy link
Member Author

pkwarren commented Jun 2, 2025

This should unblock #309 and future JUnit updates.

@andrewparmet
Copy link
Collaborator

I strongly prefer Truth to AssertJ for personal historical reasons (it's bailed me out of some tricky failed tests with better error messaging), but the usage here isn't so complex that I think we'll fall prey to those problems.

If it's a JUnit 4 dependency that's causing the issue, does a transitive exclusion work? I'd also hope to see activity on Truth's issue tracker...

@pkwarren
Copy link
Member Author

pkwarren commented Jun 2, 2025

If it's a JUnit 4 dependency that's causing the issue, does a transitive exclusion work? I'd also hope to see activity on Truth's issue tracker...

I could leave out the migration off truth but since it pulled in JUnit 4 I wanted to rule that out and didn't want to mess with exclusions and adding JUnit vintage. I've had good luck with assertj in the past and the fact that it is a lighter dependency footprint is a good tradeoff to me.

I think https://github.com/bufbuild/buf-gradle-plugin/pull/310/files#diff-c0dfa6bc7a8685217f70a860145fbdf416d449eaff052fa28352c5cec1a98c06R53 is the fix to allow upgrades.

andrewparmet
andrewparmet previously approved these changes Jun 2, 2025
Copy link
Collaborator

@andrewparmet andrewparmet left a comment

Choose a reason for hiding this comment

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

We shouldn't need JUnit vintage since we don't use the JUnit 4 annotations.

I do like Truth's custom Subject technique, but hadn't encountered a need for them yet in this project.

@pkwarren pkwarren merged commit eae8d74 into main Jun 2, 2025
8 checks passed
@pkwarren pkwarren deleted the pkw/truth-to-assertj branch June 2, 2025 16:13
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.

2 participants