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
should not garbage collect snapshots when all tests are package-private #123
Comments
It's likely that the test is being run in a way that our garbage collection doesn't recognize. Do any of the following describe your test? And if not, how is the test method annotated? selfie/selfie-runner-junit5/src/main/kotlin/com/diffplug/selfie/junit5/SelfieGC.kt Lines 25 to 27 in 350dce5
|
The first one (JUnit Jupiter). Scanning the javadocs there, it sounds like maybe my snapshot is not being named correctly — it gets named like I do have the Mockito JUnit extension in the mix also, I can see if removing that has any effect. |
class NormalTestClass {
@org.junit.jupiter.api.Test
public void myTest() {
expectSelfie("blah").toMatchDisk() That's the most normal test class I can imagine. In what ways is yours different? Inner class? Custom test annotation? |
My problem seems to arise here: selfie/selfie-runner-junit5/src/main/kotlin/com/diffplug/selfie/junit5/SelfieGC.kt Lines 53 to 61 in 350dce5
Could it be the case that this only works for |
I think that must be it — changing my test method signature from
...to:
...no longer results in my snapshot being GC'd. Do you think it would take much to handle package-private test methods? Common linters complain these days if JUnit 5 tests have unnecessary visibility. |
Amazing, thanks! A fix is on the way... |
Interesting... I added a reproducer in the PR above but it is working for public/package/protected. What JRE are you on, and are you using a |
JDK: Coretto 17.0.7 (2023-04-18 LTS) No Happy to try changing any of those versions on my end if it will help shed any light! |
Fixed in The reproducer wasn't working because as long as there was at least one public method then it worked. I got fixated on the modulepath thing, but that was a red herring. Here's the commit where the reproducer fails, fixing it was straightforward from there: 8e59325 Thanks for reporting! |
You’re welcome, thank you for shipping a fix so quickly! |
Hello! Excited to start using this project.
I have a test for some generated HTML that is currently using a hard-coded fixture (barely tolerable with text blocks), and converting it with
Selfie.expectSelfie(output).toMatchDisk_TODO()
was a breeze.I am having an issue with snapshot persistence however, wherein a subsequent Gradle invocation removes the artifact, and thereafter the test fails unless I add
//SELFIEWRITE
(or revert to the_TODO()
invocation).I'll try to add more details later (environment, etc.), but for now, the useful error breadcrumb I see is:
Let me know if there's anything else besides environment info I can add later that might help track this down. I can take a swing at an MVCE if necessary too. Thanks!
The text was updated successfully, but these errors were encountered: