0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Invoke-Gherkin 使おうとすると ConvertFrom-Json の部分でエラーが出るときのワークアラウンド

Last updated at Posted at 2020-02-18

PesterでInvoke-Gherkin使おうとしたらエラーが出て使えない

  • Pester でも Gherkin でテスト書いて動かせるようになってるじゃん! すげえ! ということで試そうとしたら動かなかったので、動かす作業メモ。

環境

  • Windows10 (Microsoft Windows [Version 10.0.17763.805])
    • 日本語版
  • PSVersion 5.1.17763.771
  • Pester v4.10.1

現象

  • feature fileと step file 作って動かすと、次のようなエラーが出る。
> Invoke-Gherkin
Pester v4.10.1
Testing all features in 'C:\foo\bar\features'
ConvertFrom-Json : ',' ではなく無効な配列が渡されました。 (2589): {
  "af": {
(略)

動いた方法

  • Install-Module Pester して入った場所の C:\Program Files\WindowsPowerShell\Modules\Pester\4.10.1\lib\Gherkin\gherkin-languages.json を BOM付きのUTF-8に書き直したら動くようになった。

ダメだった方法

  • Gherkin.ps1 に Get-Content してる部分があるが、それを Get-Content -Encoding UTF8 にしても動作に変化がなかった。
  • 何か直し方間違ってるのだろうか。

feature と Steps ファイル

  • 英語以外はやはりfeatureファイルはBOM付きのUTF-8にするかしないと次のようなエラーが出て動かせない。
  • 日本語ならSteps はShift-JISでもよい。
> Invoke-Gherkin
Pester v4.10.1
Testing all features in 'C:\foo\bar\features'
Invoke-GherkinFeature : Skipped 'C:\foo\bar\features\baz.feature' because of parser error.
発生場所 C:\Program Files\WindowsPowerShell\Modules\Pester\4.10.1\Functions\Gherkin.ps1:290 文字:13
+             Invoke-GherkinFeature $FeatureFile -Pester $pester
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], MethodInvocationException
    + FullyQualifiedErrorId : System.Management.Automation.MethodInvocationException,Invoke-GherkinFeature
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?