lundi 5 juin 2017

android testBuildType not working

android {
  ...
  testBuildType "deviceTest"
  buildTypes {
    debug {
      // Using 10.0.2.2 (the desktop's localhost), as the app normally runs on an Emulator
      // in debug mode.
      buildConfigField "String", "BACKEND_URL", '"http://10.0.2.2"'
      buildConfigField "Integer", "PORT", "8080"
      applicationIdSuffix ".debug"
    }
    // Use local host for testing, for MockWebServer
    deviceTest {
      initWith debug
      buildConfigField "String", "BACKEND_URL", '"http://localhost"'
    }
    release {
      ...
    }
  }
}

Exactly like Google doc implies here. However, this causes test dependencies (like JUnit) to be unreachable from unit tests, and so the test cannot run.

Aucun commentaire:

Enregistrer un commentaire