সোমবার, ২০ এপ্রিল, ২০১৫

Setting up BDD with RoboSpock/Robolectric and Android Studio 1.1.0

Please follow the following steps to enjoy fast BDD from within your Android Studio ; -

1) Please ensure you are using Android Studio 1.1.0 or higher.


2) Please enable the 'experimental' Unit Test support feature from within the preferences pane of Android Studio




3) For projects created using older versions of Android Studio please migrate to the latest 'Android Plugin tools' version from within the Project Structure dialog box.




4) Add the following line to your app module's build.gradle file


testCompile 'org.robospock:robospock:0.5.0' // for RoboSpock
testCompile 'org.robolectric:robolectric:3.0-rc2' // for Robolectric


if you are using the Android Studio UI to add the dependencies - please ensure the libraries are added using testCompile and not androidTestCompile by inspecting the build.gradle file textually.



5) Please change the build variant on the 'Test Artifact' section of your App to 'Unit Tests' from within Android Studio.






6) Add all your TDD/BDD classes under the 'test/java' folder under src folder.





7) For Mac users - please edit the default JUnit run configuration's 'Working directory:' field to $MODULE_DIR$. For more information please click here.





8) Right click on any Test function/class and select 'Run'


More tips : -

i) Right click on any class/function and select 'Go To' -> Tests to create your Test Class automagically.

ii) Under build configurations click Edit-Configurations -> Defaults->Junit->Before Launch make with Gradle-aware-Make as shown below.




iii) For more information please click here.

iv) For a sample Robolectric project template, please click here.

কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন