0

I'm trying to write unit test for the following function in Android code,

public ClassA {

    int a = 0
    String b = null;

    @Override
    protected void fun(Bundle savedInstanceState) {
        setContentView(R.layout.a_activity_xml);
        new ClassC(context:this);
        a = getIntent().getIntExtra(ClassB.VAL1, ClassB.VAL2);
        b = getIntent().getIntExtra(ClassB.VAL3, ClassB.VAL4);
    }
}
 

Following is the @Test function I'm writing to test it, (it's showing errors)


@Test
public void funTest() {

    Whitebox.setInternalState(a_obj, "a", 
        Intent.getIntent().getIntExtra(ClassB.VAL1, ClassB.VAL2));

    Whitebox.setInternalState(a_obj, "b", 
        Intent.getIntent().getIntExtra(ClassB.VAL3, ClassB.VAL4));

}
Bonniu
  • 120
  • 1
  • 2
  • 14
  • [Why is my class not calling my mocked methods in unit test?](https://stackoverflow.com/q/74027324/112968) – knittl Dec 20 '22 at 07:39

0 Answers0