Skip to content

Instantly share code, notes, and snippets.

@AlexZhukovich
AlexZhukovich / app-module-build.gradle
Created November 13, 2016 09:47
Import an external module to Android Project in Android Studio (http://alexzh.com/tutorials/import-an-external-module-in-android-studio/)
//ExternalModulesInProject/Application/app
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.alexzh.application"
minSdkVersion 14
targetSdkVersion 25
@AlexZhukovich
AlexZhukovich / module-build.gradle
Last active October 23, 2017 14:13
Versions managing of dependencies in Gradle
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.alexzh.temperatureconverter"
minSdkVersion 14
@AlexZhukovich
AlexZhukovich / TestDataFactory
Created February 1, 2019 21:38
TestDataFactory
object TestDataFactory {
fun randomString(): String {
return UUID.randomUUID().toString()
}
fun randomDouble(): Double {
return Math.random()
}
@AlexZhukovich
AlexZhukovich / Dependencies
Created February 1, 2019 21:41
Sharing test cases between local and instrumentation tests - dependencies
dependencies {
...
// Robolectric
testImplementation "org.robolectric:robolectric:$robolectric_version" // 4.1
// Android test runner and rules
androidTestImplementation "androidx.test:runner:$test_runner_version" // 1.1.0
androidTestImplementation "androidx.test:core:$test_core_version" // 1.1.0
androidTestImplementation "androidx.test.ext:junit:$test_junit_version" // 1.1.0
androidTestImplementation "androidx.test:rules:$test_rules_version" // 1.1.0
@AlexZhukovich
AlexZhukovich / UiAutomatorSignInTest.kt
Last active September 7, 2019 23:52
Sign In error verification Android UI tests with UiAutomator
@RunWith(AndroidJUnit4::class)
class UiAutomatorSignInTest {
companion object {
const val LAUNCH_TIMEOUT = 2_000L
const val APP_PACKAGE = "com.alex.mapnotes"
}
private val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
@AlexZhukovich
AlexZhukovich / EspressoSignInTest.kt
Last active September 7, 2019 23:52
Sign In error verification Android UI tests with Espresso
@RunWith(AndroidJUnit4::class)
class EspressoSignInTest {
@Rule @JvmField
val activityRule = ActivityTestRule<SignInActivity>(SignInActivity::class.java)
@Test
fun shouldDisplaySinInErrorWhenEmailIsIncorrect() {
val incorrectEmail = "test"
@AlexZhukovich
AlexZhukovich / AppiumSignInTest.kt
Created September 7, 2019 23:53
Sign In error verification Android UI tests with Appium
class AppiumSignInTest {
private lateinit var appiumDriver: AppiumDriver<AndroidElement>
@Before
fun setup() {
val capabilities = DesiredCapabilities()
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, "Android")
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "emulator-5554")
capabilities.setCapability("appPackage", "com.alex.mapnotes")
@LargeTest
@RunWith(AndroidJUnit4::class)
class SignInActivityTest123 {
@Rule
@JvmField
var mActivityTestRule = ActivityTestRule(SignInActivity::class.java)
@Test
fun signInActivityTest123() {
val appCompatEditText = onView(
allOf(withId(R.id.email),
dependencies {
...
implementation 'androidx.compose:compose-compiler:0.1.0-dev04'
implementation 'androidx.compose:compose-runtime:0.1.0-dev04'
implementation 'androidx.ui:ui-layout:0.1.0-dev04'
implementation 'androidx.ui:ui-framework:0.1.0-dev04'
implementation 'androidx.ui:ui-layout:0.1.0-dev04'
implementation 'androidx.ui:ui-foundation:0.1.0-dev04'
implementation 'androidx.ui:ui-animation:0.1.0-dev04'
implementation 'androidx.ui:ui-tooling:0.1.0-dev04'
android {
...
composeOptions {
kotlinCompilerExtensionVersion "0.1.0-dev04"
}
}