Reputation: 5442
My app uses versionName
of it's PackageInfo
to determine the current version.
I'm trying to test a piece of code (using JUnit
) the relies on that data, but Robolectric set versionName
to null.
I looked into the source code and saw that the PackageInfo
is initialized according to my AndroidManifest.xml
.
My app's manifest doesn't contains versionName, it is set via android gradle plugin (which works great after a regular build, and I would like to keep it that way)
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
defaultConfig {
...
versionName VERSION_NAME
}
...
}
Any ideas how I can make the changes to the manifest occur in a test build?
Upvotes: 1
Views: 819
Reputation: 20140
You can use BuildConfig.VERSION_NAME
constant instead of gathering it from PackageInfo
.
However because Robolectric
tests are run only for debug configuration it is not possible to check in Robolectric
tests release configuration cases. But maybe it is not your case
Upvotes: 0