Unit Testing

Command Line

Android unit tests run on your device or in an emulator. They're located in the blocklytest directory. You can run the tests from the command line using gradle from the repository root:

blockly-android$ ./gradlew cC

Or, for more succinct output:

blockly-android$ ./gradlew -q cC

If the tests can't find your device or emulator, you'll get the following error message:

* What went wrong:
Execution failed for task ':blocklytest:connectedDebugAndroidTest'.
> com.android.builder.testing.api.DeviceException: No connected devices!

Check adb devices and your emulator or device's connections.

Android Studio

Android Studio can also run the tests. In the Project subwindow, using the Project tree view, right-click the blocklytest module and select Run. You can also run individual test cases by similarly right-clicking the test file and selecting Run.

Running tests through the Android Studio UI

Android Studio presents a dialog to select a connected device or start an emulator.