diffplug / diffplug/selfie

toMatchDisk_TODO throws error when writing multiple snapshots to disk during parameterized tests, succeeds on follow ups.

Abierto
#370 1 comentario 1 reacción 0 asignados Ver en GitHub
bug jvm
Lenguaje dominante
Kotlin
Estrellas
101
Forks
18
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

I am using `selfie-runner-junit5:2.0.1` to verify errors for each test case. I my parameters include a unique test case name to pass into `toMatchDisk`.

The summarized version:

```kotlin
@ParameterizedTest(name = "rejects invalid commands: {1}")
@MethodSource("modifyNodeItemsValidationCases")
fun `rejects invalid commands`(
cmd: Command,
testcaseName: String,
) = runTest {
val thrown = shouldThrow {
validate(cmd)
}
thrown.response.respCase shouldBe RespCase.RESPONSE_BAD_REQUEST
Selfie.expectSelfie(thrown.message.toString()).toMatchDisk(testcaseName)
}
```

When I run this test case, the snapshot file is successfully written:

```
╔═ rejects invalid commands/Child node not found ═╗
ModifyItem must have a valid item case to modify
╔═ rejects invalid commands/Empty modify item ═╗
ModifyItem must have a valid item case to modify
╔═ rejects invalid commands/Empty modify node item ═╗
ModifyNodeItemWithAddition must have either modifyItem, updateExistingTraits, modifyChildElectricalConnectionPoints, or upstreamElectricalConnectionPoint
╔═ rejects invalid commands/No UtilityMeterNode when trying to edit a utility meter node ═╗
No UtilityMeterNode item found for node id 1 in topology
╔═ rejects invalid commands/Node not found ═╗
Provided node id 1 not in topology
╔═ rejects invalid commands/empty modifyDownstreamElectricalConnectionPoint ═╗
ModifyItem must have a valid item case to modify
╔═ rejects invalid commands/empty simpleElectricalConnectionPoint ═╗
ModifyItem must have a valid item case to modify
╔═ [end of file] ═╗

```

But the first run fails with this error:

```
org.opentest4j.AssertionFailedError: Snapshot was set to multiple values!
first time: ValidatorTest$rejects invalid commands$1.invokeSuspend(Validator.kt:613)
this time: ValidatorTest$rejects invalid commands$1.invokeSuspend(Validator.kt:613)
```

Once the file is created things seem to work:

- Subsequent test runs pass
- If I modify one or more of the expected value and include `//selfieonce` the updates are made and tests pass
- Add one or more new test case with `//selfieonce`

I can produce the same errors again if the file exists if I ever reuse the `_TODO`.

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza con el reproductor parametrizado de Kotlin usando selfie-runner-junit5:2.0.1 e inspecciona el fallo en Validator.kt:613. Compara la primera ejecución, cuando se crea el archivo de snapshot, con las ejecuciones posteriores y con la reutilización de un _TODO existente; la tarea estará terminada cuando se puedan escribir varios snapshots sin el error “Snapshot was set to multiple values!”.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
kotlin
Área
testing
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
38/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.