Difference between Android Instrumentation test and Unit test in Android Studio?

后端 未结 6 1902
被撕碎了的回忆
被撕碎了的回忆 2020-12-12 11:20

As of Android Studio 1.1rc there\'s Unit testing support and I\'m wondering what\'s the difference between Android Instrumentation Tests and Unit tests.

6条回答
  •  一整个雨季
    2020-12-12 11:39

    It seems to me that instrumentation testing is integration testing with the ability to control the life cycle and the events (onStart, onCreate etc) of the app.

    Unit testing, as i understand it, is testing a Unit (eg Class) for its data and behavior.

    For example, say you have a game: this game runs on an activity (main activity) and you have a character based on a Robot class, that has 2 methods (fire and move). You would test the main activity with an instrumentation test to see if it saves correctly when you leave the app, if it restores correctly when you restore it etc. and you would test Robot with a Unit test, to test its attributes and behavior.

    Disclaimer: I'm not a java person, but i took interest in your question and i answered it based on a minor search online. You probably have to dig deeper into this to find a more detailed answer.

提交回复
热议问题