Android Base64 encode and decode return null in Unit Test

前端 未结 4 1464
失恋的感觉
失恋的感觉 2021-02-18 18:21

I am attempting to decode a Base64 encoded string in Android using the http://developer.android.com/reference/android/util/Base64.html class.

Both the encodeToString and

4条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-18 18:55

    You can use the Robolectric Runner

    1. Add the dependency in your build.gradle:

      testCompile 'org.robolectric:robolectric:X.X.X'
      
    2. Add this line in your testing class:

      import org.junit.runner.RunWith;
      import org.robolectric.RobolectricTestRunner;
      
      @RunWith(RobolectricTestRunner.class)
      public class MyTestingClassTest {
          ...
      }
      

提交回复
热议问题