1
1

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 3 years have passed since last update.

Rustで特定のテストを走らせる方法

Posted at

いつもいつもどうやってやるんだったか思い出せません。

ということでメモ。

How to run a specific unit test in Rustを読んでもなおハマりました。

このテストだけ実行したいのだけど、このテストだけってどうやって呼び出すんだったかいな・・・・えーとディレクトリ名が・・・

とかやってるあなた向けです。

今北産業

cargo test --all func_name_of_test

ポイントは--allです。とりあえずこれだけ覚えとけばいいような気がします。

欠点

  • func_name_of_test1
  • func_name_of_test2
  • func_name_of_test3

というテストがあったとき全部実行されます。大変うざいです。
これは名前をきちんと指定するしかないですね。

すべてのcrateのテストを実行するので出力も多くなります。


running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

     Running target/debug/deps/xxxx

が大量に出てきます。
(消す方法知ってる人は教えて下さい。)

なんでハマったか

基本は

cargo test func_name_of_test

です。

ただこれ、crateがたくさん入ってるようなコードベースだと、上手く行かないようです。

exactは?

cargo test --all -- --exact func_name_of_test

ではダメで

cargo test --all -- --exact foo::tests::func_name_of_test

みたいにフルで指定しないといけないようです。

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?