I want to test the class below using junit and mockito but no other third party library.
Below is my Logger wrapper class
import android.util.Log
public class Logger{
public static void v(String tag,String logMessage){
Log.v(tag,logMessage);
}
public static void v(String tag,String logMessage,Throwable throwable){
Log.v(tag,logMessage);
}
}
Below is how I try to unit test the above class
import android.util.Log;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.mockito.junit.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
public class ModelTest {
@Before
public void setup(){
when(Logger.v(anyString(),anyString())).thenCallRealMethod(Log.v(anyString(),anyString()));
when(Logger.v(anyString(),anyString()),any(Throwable.class)).thenCallRealMethod(Log.v(anyString(),anyString()));
}
@Test
public void v(){
Logger.v("Tag.v"," Message from Tag.v");
Logger.v("Tag.v throw"," Message from Tag.v throw");
}
}
In the Before, when() method is not accepting anyString() type. Please, any before approach. I will really appreciate