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?

Fluent Assertionsからの乗り換え

Last updated at Posted at 2025-10-14

Fluent Assertionsは便利

Fluent AssertionsはユニットテストのAssertを書きやすくするライブラリ。

Assert.Equal("1", str);

これを、以下のような形で書けるようにしてくれます。

str.Should().Be("1");

他にも機能があるので、興味がある方は以下を読むといいかもしれません。

また、Assertionに失敗したとき出力されるエラーメッセージがわかりやすくなる機能もあります。

Version 8から商用利用に有料ライセンスが必要に

ちょっと(ずいぶん?)古い話題なんですが、このFluent AssertionsはVersion 8から有料ライセンスが必要になりました。

Versions 8 and beyond are free for open-source projects and non-commercial use, but commercial use requires a paid license. Check out the license page for more information. Version 7 will remain fully open-source indefinitely and receive bugfixes and other important corrections.

なお、基本ライセンスは、1名の開発者向けライセンスにつき14.95$/年(サポートなし)です。

インフレの世の中だからね。しかたないね。
でも、ちょっとお高めですな!?

Awesome Assertionsというフォークができていた

もちろん、Version 7のまま使いつづけるという手もあるんですが、何かの拍子でVersion 8にアップデートしかねない。
新しいプロジェクトを作るときに、Fluent Assertionsの最新版を持ってこないとも限らない。

とおもっていたら、

というフォークができていた。

Fluent AssertionsのVersion 8直前からフォークされていて、NuGetパッケージになっているので、Fluent AssertionsのVersion 7から簡単に乗り換え可能。
Version 8以降もリリースされているようで、フォークされただけのプロジェクトではない。

ChainingAssertion → Fluent Assertionsと移行してきたんですが、もうこの手のAssertionパッケージがないとテストを書きたくない。
Shouldlyあたりに乗り換えないといけないかと思いましたが、当面はこれを使わせていただこう。

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?