From ad3a930e346ad54acd8e895b01418f7b936776dd Mon Sep 17 00:00:00 2001 From: Damien Arrachequesne Date: Mon, 11 Jul 2022 10:11:34 +0200 Subject: [PATCH] docs: how to run unit tests in Android Studio Related: https://github.com/socketio/socket.io-client-java/issues/493 --- src/site/markdown/android.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/site/markdown/android.md b/src/site/markdown/android.md index a33b2f9..be5c790 100644 --- a/src/site/markdown/android.md +++ b/src/site/markdown/android.md @@ -57,3 +57,27 @@ Starting with Android 9 (API level 28) you need to explicitly allow cleartext tr ``` Reference: https://developer.android.com/training/articles/security-config + +## How to run unit tests in Android Studio? + +Local unit tests are tests that run on your machine's local Java Virtual Machine. + +Reference: https://developer.android.com/studio/test/test-in-android-studio + +Since they run on your machine, the JSON library must be manually included for the tests (because it is not provided by the Android runtime): + +`build.gradle` + +``` +dependencies { + implementation ('io.socket:socket.io-client:2.0.1') { + exclude group: 'org.json', module: 'json' + } + + testImplementation 'org.json:json:20090211' + + ... +} +``` + +Note: we use this ancient version of `org.json` because it is compatible with the one bundled in Android.