java - Android local unit test - new View(null) returns null -


i'm experimenting local android tests (the ones run on local jvm, not on device). understand classes in android.jar can't used unless mocked, reason when try instantiate new view (or own class inherited view)- null. totally breaks belief "new" never returns null in java.

here's test code (src/test/java/com/example/footest.java):

package com.example;  import android.view.view; import org.junit.test;  public class footest {     @test     public void testview() {         view v = new view(null);         system.out.println("view = " + v);     } } 

this code prints in test report output view null.

here's build.gradle (the rest of project generated android create project , of no interest):

buildscript {     repositories {         jcenter()     }     dependencies {         classpath 'com.android.tools.build:gradle:1.3+'     } } apply plugin: 'android'  android {     compilesdkversion 'android-22'     buildtoolsversion '23.0.0 rc2'      buildtypes {         release {             minifyenabled false             proguardfile getdefaultproguardfile('proguard-android.txt')         }     }      testoptions {         unittests.returndefaultvalues = true     } }  repositories {     jcenter(); }  dependencies {     testcompile 'junit:junit:4.12+' } 

can give clues kind of magic happening here?

this code tells string representation (i.e. see tostring() of view) "null" not v null.

afaik, new something() never null in java


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -