Reputation: 1468
I have a question about testing some Android code. I'm currently making some JSON to Object converting code and it's very annoying to keep going into the emulator and seeing if it works.
I'm curious if there is a way to do this faster, for example without running the emulator?
Thanks in advance.
Upvotes: 7
Views: 5682
Reputation: 1
Suppose you are working in TestActivity.java file . Make your TestActivity.java class as Launcher in manifest file. If your class takes some inputs from previous activity then hardcode those inputs as "Strings" . its not the best of the best solution but it can save a lot of your time by directly going to the point you want to go.
Upvotes: 0
Reputation: 311
Now with Kotlin, it is possible to quickly execute some piece of code without running in emulator or device.
Suppose you have a class like this
class MyTestClass() {
init {
println("This is from Init")
}
}
you can quickly run this by creating a main function on top and running it.
fun main(){
val myClass = MyTestClass()
}
class MyTestClass() {
init {
println("This is from Init")
}
}
Upvotes: 5
Reputation: 6546
You should be able to run/test your code directly on your laptop or PC by calling your code inside test folder,
You just want to test the data result of JSON or corresponding object(s), in this case you can just get the result directly on your laptop and there is no need to run any emulators, for these kinds of tests there is "Unit test" which helps you to run your code and check the results, and this is the fastest way you to run without emulator.
Upvotes: 1
Reputation: 89
This is impossible, but if you want to gain more time, use the genymotion emulator is faster then the Android Studio emulator.
Upvotes: 3
Reputation: 1550
Plug in an android phone, turn on debugging mode in developer options. Way faster to upload test apks and faster, especially if you have a slower pc.
Upvotes: 0