在android kitkat中,URLConnection的实现已被OkHttp取代,它如何调试呢?
OkHttp在这个目录中:external/okhttp/android/main/java/com/squareup/okhttp
当我打电话给UrlInstance.openConnection().getClass().getName()它时,它会出现com.android.okhttp.internal.http.HttpURLConnectionImpl
我该怎么调试呢?似乎我无法联想/android/main/java/com/squareup/okhttp/*到com.android.okhttp.*
当代码执行到 return streamHandler.openConnection(this);
/**
* Returns a new connection to the resource referred to by this URL.
*
* @throws IOException if an error occurs while opening the connection.
*/
public URLConnection openConnection() throws IOException {
return streamHandler.openConnection(this);
}
Run Code Online (Sandbox Code Playgroud)
向前走,但不能深入挖掘 com.squareup.okhttp.HttpHandler#openConnection
下图中调试器中突出显示的线程为灰色.
package com.squareup.okhttp;
import java.io.IOException;
import java.net.Proxy;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLStreamHandler;
public class HttpHandler extends URLStreamHandler {
@Override protected URLConnection openConnection(URL url) throws IOException { …Run Code Online (Sandbox Code Playgroud) 我认为instruementTest中的测试应该与android有关,所以我需要添加一个addtional源文件夹,比如src/test/java?它看起来src/test/java中的testfile没有编译.
我怎样才能独立运行junit测试?
我怎样才能在命令行中运行junit测试,没有关于android的instrumentTest?


或者在instruementTest文件夹中输入和junit测试并调用
./gradlew connectedInstrumentTest
Run Code Online (Sandbox Code Playgroud)
但是,单元测试根本不会运行.