[Enhancment] Calling `expectSelfie()` from another package
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện ví dụ ErrorSpec giữa các package và kiểm tra SelfieImplementations/DiskSelfie.toMatchDisk(), đặc biệt là hành vi quanh dòng 38 và việc tra cứu mã nguồn của CallLocation. So sánh nó với toMatchDisk_TODO(). Hoàn thành có nghĩa là public API có thể xác thực và ghi các snapshot từ một package khác mà không phụ thuộc vào hành vi TODO hoặc ghi đè chúng trong mỗi lần chạy.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hello, the library is pretty useful, but I'm stumbling into a problem that I'm not sure how to fix.
Using Kotest, I want to create a reusable Spec to snapshot tests my custom exceptions and their localization.
It ends up looking kind of like this:
package mypackage.errors
abstract class ErrorSpec<T : Error>(
private val clazz: KClass<T>,
private val create: () -> T
) :
FunSpec({
context("Localisation") {
forAll(Exhaustive.collection(SUPPORTED_LOCALES)) {
expectSelfie(json.encodeToString(clazz.serializer(), create())).toMatchDisk()
}
}
})
class ErrorTest : ErrorSpec<Error>(
clazz = Error::class,
create = { Error() }
)
This work perfectly, until I put ErrorSpec in another package.
The main reason I want to do this is to use a testFixtures.
This then ends up failing at runtime with:
org.opentest4j.AssertionFailedError:
Couldn't find source file for CallLocation(
clazz=mypackage.ErrorSpec$1$1,
method=invokeSuspend,
fileName=Specs.kt,
line=36
),
looked in TypedPath(absolutePath=[...]/mypackage/src/test/kotlin/)
and [[...]/mypackage/src/test/resources],
maybe there are other source roots?
What I don't understand is that, if I use toMatchDisk_TODO() instead of toMatchDisk(), the snapshot files end up being written, but the tests fails on writeLine.
Manually changing the value of isTodo to true in SelfieImplementations/DiskSelfie.toMatchDisk():38, the tests pass successfully, with the snapshot file being written at the correct place (albeit being overwritten every run, which kind of defeat the point).
Is there a way to do what I want using the public API?
If not, would it be possible to implement?
- Ngôn ngữ chính
- Kotlin
- Star
- 101
- Fork
- 18
- Merge trung bình
- 6 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 5
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của diffplug/selfie
-
Selfie JVM Snapshot Garbage Collection is overly zealous when using multiple test suites in gradle Đang mởbug jvm
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
-
enhancement jvm
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
bug jvm
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
bug docs jvm
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 50/100
-
bug jvm py
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 48/100
Tất cả issue của diffplug/selfie
Issue tương tự
-
[Bug] 统计页面无法重置token和汇率 Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
AAswordman/Operit#1265 · 3 bình luận ·
-
Tambahkan bahasa Indonesia Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
acristescu/OnlineGo#216 ·
-
Remove custom segment colors Đang mởenhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
libre-tube/LibreTube#8803 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
status: waiting-for-triage type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
spring-projects/spring-security#19781 ·