[jvm] Snapshots are not being written to disk when there are tests with numbered names
还没有人认领这个 Issue。
评估
调研方向
首先在 IntelliJ 中使用 Selfie 2.5.3 运行提供的 JUnit 5 ReproduceSelfieBugTest 示例,然后检查针对带编号测试名称的 snapshot 文件是如何写入和排序的。在添加或删除测试并重新运行文件后,foo10、test10 和 testFoo10 仍能始终存在于 .ss 文件中,即表示完成。
由索引模型根据 Issue 内容生成。
描述
There is an issue when creating test methods that are numbered (e.g. test1(), test2(), ...). At some point snapshots of tests are no longer written to disk. I discovered this while writing integration tests for a Spring Boot app that I generically name test1(), test2() etc. because I use @DisplayName anyway.
I cannot disclose the actual code but here is an example test file using JUnit 5, Java 21 and Selfie 2.5.3 that I could reproduce this with:
import com.diffplug.selfie.Selfie;
import org.junit.jupiter.api.Test;
class ReproduceSelfieBugTest {
//SELFIEWRITE
@Test
void test() {
Selfie.expectSelfie("0").toMatchDisk();
}
@Test
void test1() {
Selfie.expectSelfie("1").toMatchDisk();
}
@Test
void test2() {
Selfie.expectSelfie("2").toMatchDisk();
}
@Test
void test3() {
Selfie.expectSelfie("3").toMatchDisk();
}
@Test
void test4() {
Selfie.expectSelfie("4").toMatchDisk();
}
@Test
void test5() {
Selfie.expectSelfie("5").toMatchDisk();
}
@Test
void test6() {
Selfie.expectSelfie("6").toMatchDisk();
}
@Test
void test7() {
Selfie.expectSelfie("7").toMatchDisk();
}
@Test
void test8() {
Selfie.expectSelfie("8").toMatchDisk();
}
@Test
void test9() {
Selfie.expectSelfie("9").toMatchDisk();
}
@Test
void test10() {
Selfie.expectSelfie("10").toMatchDisk();
}
@Test
void testFoo() {
Selfie.expectSelfie("testFoo").toMatchDisk();
}
@Test
void testFoo1() {
Selfie.expectSelfie("testFoo1").toMatchDisk();
}
@Test
void testFoo2() {
Selfie.expectSelfie("testFoo2").toMatchDisk();
}
@Test
void testFoo3() {
Selfie.expectSelfie("testFoo3").toMatchDisk();
}
@Test
void testFoo4() {
Selfie.expectSelfie("testFoo4").toMatchDisk();
}
@Test
void testFoo5() {
Selfie.expectSelfie("testFoo5").toMatchDisk();
}
@Test
void testFoo6() {
Selfie.expectSelfie("testFoo6").toMatchDisk();
}
@Test
void testFoo7() {
Selfie.expectSelfie("testFoo7").toMatchDisk();
}
@Test
void testFoo8() {
Selfie.expectSelfie("testFoo8").toMatchDisk();
}
@Test
void testFoo9() {
Selfie.expectSelfie("testFoo9").toMatchDisk();
}
@Test
void testFoo10() {
Selfie.expectSelfie("testFoo10").toMatchDisk();
}
@Test
void foo() {
Selfie.expectSelfie("foo").toMatchDisk();
}
@Test
void foo1() {
Selfie.expectSelfie("foo1").toMatchDisk();
}
@Test
void foo2() {
Selfie.expectSelfie("foo2").toMatchDisk();
}
@Test
void foo3() {
Selfie.expectSelfie("foo3").toMatchDisk();
}
@Test
void foo4() {
Selfie.expectSelfie("foo4").toMatchDisk();
}
@Test
void foo5() {
Selfie.expectSelfie("foo5").toMatchDisk();
}
@Test
void foo6() {
Selfie.expectSelfie("foo6").toMatchDisk();
}
@Test
void foo7() {
Selfie.expectSelfie("foo7").toMatchDisk();
}
@Test
void foo8() {
Selfie.expectSelfie("foo8").toMatchDisk();
}
@Test
void foo9() {
Selfie.expectSelfie("foo9").toMatchDisk();
}
@Test
void foo10() {
Selfie.expectSelfie("foo10").toMatchDisk();
}
}
Running this test file in IntelliJ 2024.3 produces this ReproduceSelfieBugTest.ss file:
╔═ foo ═╗
foo
╔═ foo1 ═╗
foo1
╔═ foo2 ═╗
foo2
╔═ foo3 ═╗
foo3
╔═ foo4 ═╗
foo4
╔═ foo5 ═╗
foo5
╔═ foo6 ═╗
foo6
╔═ foo7 ═╗
foo7
╔═ foo8 ═╗
foo8
╔═ foo9 ═╗
foo9
╔═ test ═╗
0
╔═ test1 ═╗
1
╔═ test2 ═╗
2
╔═ test3 ═╗
3
╔═ test4 ═╗
4
╔═ test5 ═╗
5
╔═ test6 ═╗
6
╔═ test7 ═╗
7
╔═ test8 ═╗
8
╔═ test9 ═╗
9
╔═ testFoo ═╗
testFoo
╔═ testFoo1 ═╗
testFoo1
╔═ testFoo2 ═╗
testFoo2
╔═ testFoo3 ═╗
testFoo3
╔═ testFoo4 ═╗
testFoo4
╔═ testFoo5 ═╗
testFoo5
╔═ testFoo6 ═╗
testFoo6
╔═ testFoo7 ═╗
testFoo7
╔═ testFoo8 ═╗
testFoo8
╔═ testFoo9 ═╗
testFoo9
╔═ [end of file] ═╗
You will notice the snapshots for these tests are missing: foo10(), test10(), testFoo10, i.e. all tests ending with 10.
Additional information:
If you remove ALL tests except test(), test1() and test10() then the snapshot for test10() is correctly saved to disk.
After that, if test2() is added back and after re-running the test file, the snapshot for test10() is missing again. Then, after removing test2() once more and re-running the test file, the snapshot for test10() is STILL missing until the test file is run one more time.
- 主要语言
- Kotlin
- 星标
- 101
- 派生
- 18
- 平均合并
- 6 天 11 小时
- 30 天内合并 PR
- 5
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
diffplug/selfie 的其他 Issue
-
Selfie JVM Snapshot Garbage Collection is overly zealous when using multiple test suites in gradle未关闭bug jvm
难度 4/5 3-5 天 新手友好度 48/100
-
enhancement jvm
难度 5/5 一周以上 新手友好度 25/100
-
bug jvm
难度 4/5 3-5 天 新手友好度 35/100
-
bug docs jvm
难度 2/5 1-3 小时 新手友好度 50/100
-
bug jvm py
难度 2/5 1-3 小时 新手友好度 48/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
micronaut-projects/micronaut-core#13717 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
-
Bug Domain changed
难度 1/5 1 小时以内 新手友好度 70/100
keiyoushi/extensions-source#19690 · 1 条评论 ·
维护者通常 1 天内回复
-
Missing repro Platform: Android
难度 2/5 1-3 小时 新手友好度 78/100
software-mansion/react-native-reanimated#10816 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
KazumaProject/JapaneseKeyboard#1125 ·
维护者通常 1 天内回复