AppHelper { public static int getAppVersionCode(Context context) { int currVersionCode = 0; try { PackageInfo pInfo = AppHelper.getPackageInfo(context); currVersionCode = pInfo.versionCode; } catch (NameNotFoundException e) { Dbg.printStackTrace(e); } return currVersionCode; } private  AppHelper(); static void debugPrintSignatures(Context context); static int getSignaturesHashCode(Context context); static String getAppLabel(Context context); static String getAppVersion(Context context); static int getAppVersionCode(Context context); static int getApkAppVersionCode(Context context, String apkFullPath); static PackageInfo getPackageInfo(Context context); static String getPackageNameFromApk(Context context, String fileName); static long getApkBuildDate(Context context); static boolean isAppInstalledToSDCard(Context context); static void removeApplication(Context context, String pkgName); static void installApplication(Context context, File file); static boolean isPackageExisted(Context context, String targetPackage);  }
@Test public void testGetAppVersionCode() throws Exception { final int code = AppHelper.getAppVersionCode(getTargetContext()); assertEquals(Integer.parseInt(getProperty("versionCode")), code); }