[Enhancment] Calling `expectSelfie()` from another package
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 35/100
Línea de trabajo
Empieza reproduciendo el ejemplo de ErrorSpec entre paquetes e inspecciona SelfieImplementations/DiskSelfie.toMatchDisk(), especialmente el comportamiento alrededor de la línea 38 y la búsqueda del código fuente de CallLocation. Compáralo con toMatchDisk_TODO(). Se considera terminado cuando la API pública puede validar y escribir snapshots desde otro paquete sin depender del comportamiento de TODO ni sobrescribirlos en cada ejecución.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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?
- Lenguaje dominante
- Kotlin
- Estrellas
- 101
- Forks
- 18
- Merge medio
- 6 d 11 h
- PR fusionados (30 d)
- 5
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de diffplug/selfie
-
Selfie JVM Snapshot Garbage Collection is overly zealous when using multiple test suites in gradle Abiertobug jvm
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
-
enhancement jvm
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
-
bug jvm
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
-
bug docs jvm
Dificultad 2/5 1-3 horas Aptitud para principiantes 50/100
-
bug jvm py
Dificultad 2/5 1-3 horas Aptitud para principiantes 48/100
Todos los issues de diffplug/selfie
Issues similares
-
Remove custom segment colors Abiertoenhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
libre-tube/LibreTube#8803 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 75/100
-
Telegram !!! Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Xposed-Modules-Repo/com.fuck.iab#24 · 3 comentarios · 1 reacción ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
SimonHalvdansson/Harmonic-HN#361 ·