Skip to content

[jvm] duplicated filename creates exceptions when updating snapshot #552

Open

Description

@AlbRoehm

There is a possible issue that I encountered with duplicated file names of tests. (in different packages). The assertion was marked for overwrite with toBe_TODO() and the following exception was thrown:

[com.diffplug.selfie.junit5.SelfieTestExecutionListener] threw exception for method: testPlanExecutionFinished(org.junit.platform.launcher.TestPlan@65b49da9) java.lang.AssertionError: Expected to find inline assertion on line ... 

With some debugging i found that there was a file with a identical name red with different content instead of the correct one, before the exception was thrown.

Also I'm not sure if this a known limitation or a bug

Activity

  1. nedtwigg commented on Oct 11, 2025

    @nedtwigg
    Member

    Huh. Definitely sounds like a bug. Can you share more detail in the stacktrace or the package names causing the conflict?

  2. AlbRoehm commented on Oct 14, 2025

    @AlbRoehm
    Author

    The package/file name is base.routes.internal.RequestRoutesTest.kt and base.routes.exposed.RequestRoutesTest.kt. The test itself ends successfully, but the gradle logs contain the following stacktrace. Playing around the file name showed that moving to two different names hides the issue and moving to anything else identical for both files brings it back.

    I will try to setup a minimal example to see if I can reproduce it more easily.

    RequestRoutesTest > PostRequest > Provide invalid authentication, returns auth failure() PASSED
    
    Oct 14, 2025 3:44:28 PM org.junit.platform.launcher.core.CompositeTestExecutionListener lambda$notifyEach$21
    WARNING: TestExecutionListener [com.diffplug.selfie.junit5.SelfieTestExecutionListener] threw exception for method: testPlanExecutionFinished(org.junit.platform.launcher.TestPlan@7e642f83)
    java.lang.AssertionError: Expected to find inline assertion on line 136, but there was only `                        ): Either<Problem, Request> = testNotImplemented()`
    	at com.diffplug.selfie.guts.SourceFile.parseToBeLike(SourceFile.kt:119)
    	at com.diffplug.selfie.guts.InlineWriteTracker.persistWrites(WriteTracker.kt:215)
    	at com.diffplug.selfie.junit5.SnapshotSystemJUnit5.finishedAllTests(SnapshotSystemJUnit5.kt:111)
    	at com.diffplug.selfie.junit5.SelfieTestExecutionListener.testPlanExecutionFinished(SelfieTestExecutionListener.kt:75)
    	at org.junit.platform.launcher.core.CompositeTestExecutionListener.lambda$testPlanExecutionFinished$14(CompositeTestExecutionListener.java:88)
    	at org.junit.platform.launcher.core.CompositeTestExecutionListener.lambda$notifyEach$21(CompositeTestExecutionListener.java:110)
    	at org.junit.platform.commons.util.CollectionUtils.forEachInReverseOrder(CollectionUtils.java:263)
    	at org.junit.platform.launcher.core.IterationOrder$2.forEach(IterationOrder.java:30)
    	at org.junit.platform.launcher.core.CompositeTestExecutionListener.notifyEach(CompositeTestExecutionListener.java:108)
    	at org.junit.platform.launcher.core.CompositeTestExecutionListener.testPlanExecutionFinished(CompositeTestExecutionListener.java:87)
    	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:105)
    	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:64)
    	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:150)
    	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:63)
    	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:109)
    	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:91)
    	at org.junit.platform.launcher.core.DelegatingLauncher.execute(DelegatingLauncher.java:47)
    	at org.junit.platform.launcher.core.InterceptingLauncher.lambda$execute$1(InterceptingLauncher.java:39)
    	at org.junit.platform.launcher.core.ClasspathAlignmentCheckingLauncherInterceptor.intercept(ClasspathAlignmentCheckingLauncherInterceptor.java:25)
    	at org.junit.platform.launcher.core.InterceptingLauncher.execute(InterceptingLauncher.java:38)
    	at org.junit.platform.launcher.core.DelegatingLauncher.execute(DelegatingLauncher.java:47)
    	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:124)
    	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:99)
    	at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:94)
    	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:63)
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
    	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
    	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
    	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:92)
    	at jdk.proxy1/jdk.proxy1.$Proxy4.stop(Unknown Source)
    	at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:200)
    	at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:132)
    	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:103)
    	at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:63)
    	at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
    	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:122)
    	at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:72)
    	at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
    	at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
    
  3. AlbRoehm commented on Oct 14, 2025

    @AlbRoehm
    Author

    Looks like the following lines are enough to force the behavior:

    Seems to work for selfie version: 2.5.3 and 2.5.4

    package com.a
    
    import com.diffplug.selfie.coroutines.expectSelfie
    import kotlinx.coroutines.test.runTest
    import org.junit.jupiter.api.Test
    
    class SameName {
        @Test
        fun Scenario() = runTest {
            assert(false) { "This is file a, the wrong file" }
        }
    }
    package com.b
    
    import com.diffplug.selfie.coroutines.expectSelfie
    import kotlinx.coroutines.test.runTest
    import org.junit.jupiter.api.Test
    
    class SameName {
        @Test
        fun Scenario() = runTest {
            expectSelfie("123").toBe_TODO()
        }
    }

    By running test b you get:

    Oct 14, 2025 4:04:16 PM org.junit.platform.launcher.core.CompositeTestExecutionListener lambda$notifyEach$21
    WARNING: TestExecutionListener [com.diffplug.selfie.junit5.SelfieTestExecutionListener] threw exception for method: testPlanExecutionFinished(org.junit.platform.launcher.TestPlan@27646bb3)
    java.lang.AssertionError: Expected to find inline assertion on line 10, but there was only `        assert(false) { "This is file a, the wrong file" }`
    	at com.diffplug.selfie.guts.SourceFile.parseToBeLike(SourceFile.kt:119)
    	at com.diffplug.selfie.guts.InlineWriteTracker.persistWrites(WriteTracker.kt:215)
    	at com.diffplug.selfie.junit5.SnapshotSystemJUnit5.finishedAllTests(SnapshotSystemJUnit5.kt:111)
    	at com.diffplug.selfie.junit5.SelfieTestExecutionListener.testPlanExecutionFinished(SelfieTestExecutionListener.kt:75)
    	at org.junit.platform.launcher.core.CompositeTestExecutionListener.lambda$testPlanExecutionFinished$14(CompositeTestExecutionListener.java:88)
    	at org.junit.platform.launcher.core.CompositeTestExecutionListener.lambda$notifyEach$21(CompositeTestExecutionListener.java:110)
    	at org.junit.platform.commons.util.CollectionUtils.forEachInReverseOrder(CollectionUtils.java:263)
    	at org.junit.platform.launcher.core.IterationOrder$2.forEach(IterationOrder.java:30)
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingjvm

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions