Testthat: 紛らわしい結果とexpect_error()

作成日 2018年03月07日  ·  3コメント  ·  ソース: r-lib/testthat

やあ、
expect_error()関数を次のように使用しようとすると、この紛らわしい結果が得られました。

> expect_error(build_report(9), "is.character(file) is not TRUE")
Error: `build_report(9)` threw an error with unexpected message.
Expected match: "is.character(file) is not TRUE"
Actual message: "is.character(file) is not TRUE"

私がテストしている関数には、次のような簡単な検証チェックがあります

...
stopifnot(is.character(file))
...

私のビジョンが私に悪戯をしているのではないことを確認するために、出力から両方の期待値をコピーしてidentical()貼り付け、結果がTRUEことを確認しました。

私はどこかで間違っていましたか、それともこれはバグですか?

よろしく。

最も参考になるコメント

簡単な推測:一致する文字列は正規表現です。 行う

expect_error(build_report(9), "is.character(file) is not TRUE", fixed = TRUE)

正規表現を作成する必要がないようにします。

全てのコメント3件

簡単な推測:一致する文字列は正規表現です。 行う

expect_error(build_report(9), "is.character(file) is not TRUE", fixed = TRUE)

正規表現を作成する必要がないようにします。

@gaborcsardiはい、

私はこれに噛みつき続けました。 たぶん、エラーメッセージは改善される可能性があります。

このページは役に立ちましたか?
0 / 5 - 0 評価