Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

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

オープン
#370 コメント 1 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
38/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
kotlin
領域
testing

調査の方向性

selfie-runner-junit5:2.0.1 を使用するパラメーター化された Kotlin reproducer から始め、Validator.kt:613 での失敗を調査します。snapshot ファイルが作成される最初の実行を、その後の実行および既存の _TODO の再利用と比較します。「Snapshot was set to multiple values!」エラーなしで複数の snapshot を書き込めるようになれば完了です。

索引モデルが issue の本文から書いたものです。

説明

bug jvm

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:

    @ParameterizedTest(name = "rejects invalid commands: {1}")
    @MethodSource("modifyNodeItemsValidationCases")
    fun `rejects invalid commands`(
        cmd: Command,
        testcaseName: String,
    ) = runTest {
        val thrown = shouldThrow<TraitStandardResponseException> {
            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.

主要言語
Kotlin
スター
101
フォーク
18
平均マージ
6日 11時間
マージ済み PR(30日)
5

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

diffplug/selfie のほかの issue

diffplug/selfie の issue をすべて見る

似ている issue

Kotlin の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。