java - Jukito/Mockito Test with static method -


i trying test class (using jukito , mockito), unfortunately extends class, has static method call. possible somehow skip call? rather not use powermockito.

public class extends b {      @inject     public a(final string s){         super(s);     } }  public abstract class b {      private string s;      protected string m = c.get().createuniqueid(); //exception thrown here      public b(string s){         this.s = s;     } }  public class c {     private static c c; //assume never null      public static c get() {         return c;     }         public final native string createuniqueid() {}  }  @runwith(jukitorunner.class) public class atest {      @inject      a;      @test     public void onmethod1test(){     } } 

when running atest, following error:

error injecting constructor, java.lang.unsatisfiedlinkerror: c

i assumed it's because of static method, wrong?

note classes examples real classes , c class not written , can not changed (unfortunately). idea behind classes , these same, changed names , left relevant parts.

jukito claims:

the combined power of junit, guice , mockito.

but thing is: none of these products allows mock static methods.

the frameworks capable of that: powermock(ito) , jmockit.

as explained: "bypass" "deficiency" writing testable code (that avoids static calls). can't improve design, these 2 choices: use powermock(ito) testing class - or not testing it.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -