I want to build unit test from existing android project but the test folder and test class like
test are deleted. Because this is existing project and I dont know why previous developer deleted them, so I need to create new test folder for this to work.
I try add the libraries to my gradle like this :
// Required -- JUnit 4 framework testCompile 'junit:junit:4.12' // Optional -- Mockito framework testCompile 'org.mockito:mockito-core:1.10.19'
test folder and the test class inside
src folder but still not works and I can’t run the test.
any idea what the correct steps to achieve this in android studio? since the documentation only showing how to add the test library and the test class but not where to place test folder or create new test folder.
You can create a directory for your testing source code, i.e. src/test/java. You can do this from the command line or using the Project view in the Project tool window. The new directory should be highlighted in green at this point.
Also make sure to choose the correct build variant.
For more details on how to configure all this and run the tests properly, please refer http://tools.android.com/tech-docs/unit-testing-support
Hope this helps.