LoginSignup
2
3

More than 3 years have passed since last update.

android studioでのユニットテストでandroidTestと、testフォルダの違い

Posted at

androidTestと、testの違い。

Androidで、単体テストを記述すると、以下の2種類のフォルダの内どちらにテストファイルを作成しますか?と聞いてくる。

androidTest

android環境でテストを行う。androidのライブラリを使え、エミュレータ上でテストが行われるためエミュレーター固有のバグをテストすることができる。
ヘッドレスエミュレーターを立ち上げてテストするため遅い。

test

Jvm上で、テストを行う。androidのライブラリは使えないが高速。

結論

基本的に、ビジネスロジッククラスは、testフォルダでテストすることで、責務を分けることが出来そう。
Statelessなロジックを扱うだけのクラスは、pureなjavaで書かれていることが望ましいので、なるべくtestフォルダでテストするのかな。

2
3
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
2
3