Tuesday 19 January 2016

How and Where to add Test cases in Android Studio?

There are some specific rules for writing test folder in android studio related to project structure and hierarchy. In case of Espresso, Robotium and UIautomator we need to write instrumentation test cases which will be written in androidTest folder of the project. Let us see how to create that folder.

1. In android studio it is important to write instrumented functional test cases in src/androdTest/java folder and unit tests in src/Test/java.

2.Now we need to create androidTest folder. right click on the src -> New ->Folder ->Java folder


3. Click on Change Folder Location and add location src/androidTest/Java

4.  Right click on java -> New -> Package and the enter package name


5. Once the package is created then right click on the package name -> New -> Java Class give Class Name TestClass  and click on OK.


After creating the TestClass you are ready to start writing your test cases.

2 comments:

  1. I wondered upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I’ll be subscribing to your feed and I hope you post again soon.
    Mobile App Development Company
    Mobile App Development Companies

    ReplyDelete
  2. Getting error :
    null
    java.lang.IllegalAccessException: no such method: io.appium.java_client.events.EventFiringObjectFactory.lambda$0(List,Listener)boolean/invokeStatic
    java.lang.NoClassDefFoundError: org/springframework/context/support/AbstractApplicationContext
    java.lang.ClassNotFoundException: Class org.springframework.context.support.AbstractApplicationContext not found

    ReplyDelete