Closed ghost closed 1 year ago
Did you add this class's path to the manifest?
I've changed anything with original AndroidManifest.xml What do i should add to?
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.android.mobly.snippet.bundled">
<uses-feature android:name="android.hardware.telephony" android:required="false" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.AUTHENTICATE_ACCOUNTS" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_PRIVILEGED" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_NUMBERS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.READ_SYNC_SETTINGS"/>
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
<uses-permission android:name="android.permission.SEND_SMS" />
<application android:allowBackup="false"
android:name="androidx.multidex.MultiDexApplication">
<meta-data
android:name="mobly-snippets"
android:value="com.google.android.mobly.snippet.bundled.AccountSnippet,
com.google.android.mobly.snippet.bundled.AudioSnippet,
com.google.android.mobly.snippet.bundled.bluetooth.BluetoothAdapterSnippet,
com.google.android.mobly.snippet.bundled.bluetooth.profiles.BluetoothA2dpSnippet,
com.google.android.mobly.snippet.bundled.bluetooth.profiles.BluetoothHearingAidSnippet,
com.google.android.mobly.snippet.bundled.BluetoothLeAdvertiserSnippet,
com.google.android.mobly.snippet.bundled.BluetoothLeScannerSnippet,
com.google.android.mobly.snippet.bundled.LogSnippet,
com.google.android.mobly.snippet.bundled.MediaSnippet,
com.google.android.mobly.snippet.bundled.NotificationSnippet,
com.google.android.mobly.snippet.bundled.TelephonySnippet,
com.google.android.mobly.snippet.bundled.NetworkingSnippet,
com.google.android.mobly.snippet.bundled.FileSnippet,
com.google.android.mobly.snippet.bundled.SmsSnippet,
com.google.android.mobly.snippet.bundled.WifiManagerSnippet,
com.google.android.mobly.snippet.bundled.StorageSnippet" />
</application>
<instrumentation
android:name="com.google.android.mobly.snippet.SnippetRunner"
android:targetPackage="com.google.android.mobly.snippet.bundled" />
</manifest>
Oh wait, are you trying to add unit tests for a snippet java class?
Oh wait, are you trying to add unit tests for a snippet java class?
Yep, actually i want to speed up test process for snippet by creating a test class, For now, i'm using snippet_shell.py to test my function
I see. I don't think there's anything special about MBS code. You can just use Android instrumentation test to test against it as a regular Android lib.
But I don't think it's very useful bc MBS mostly calls platform APIs, which triggers actual device behaviors. Unit tests won't be able to validate these fully.
+1 to this, it would be good to have instrumentation tests for the existing snippets. Useful at minimum when changing something like AGP versions or targetSDK, to test stuff still works.
Unfortunately we don't have enough resource for this.
MBS has a lot of connectivity APIs We'd essentially need to write roboelectric tests for them. And roboelectric doesn't have good support for Android connectivity APIs to begin with..
I think this issue is thoroughly discussed here. Can file new issues when actions are ready to be taken.
Yep, I'll raise a separate issue.
I wasn't suggesting unit tests with Robolectric, but that would be good also. More some instrumentation tests that confirm things like the code passes on the target SDK, or some new platform (wear, or TV).
How you would confirm the API actually behaved though? It sounds like end to end or integration tests? Who would provide the HW to run those on?
Hello, i tried to write a test class for a specific snippet, but i cannot make it work. Any suggestion?
And here is the output when i run test case