简体   繁体   中英

console java test app in Android Studio

When I worked in Eclipse on my Android projects I had test class with main() and launched it using windows console app configuration with custom build path and libs. It was very quick to run. Test class was a part of android project, used my other classes but worked on Windows: data structures tests.

Now I am in Android Studio 3, I have "Application" configuration with minimum of options. It works the same, but it spends very much time on build because it launches "Build" command before launch, and it launches assembleDebug in turn and so on. In fact it rebuilds android app which I don't need at the moment. I need to recompile only one my test class, and this took seconds in eclipse. But if I remove "Build" from "Before launch" list, AS3 would not recompile my code changes.

How can I make AS recompile only changed file(s)? How to avoid full project rebuild each time?

The short answer: you can execute java code in JUnit test module (not android test!). It works and compiles much faster than "Application" configuration because it knows that you do not use android.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM