Skip to content

Commit

Permalink
18 testing around other components (#13)
Browse files Browse the repository at this point in the history
* updating projects

* some small tweaks
  • Loading branch information
lgleasain committed Jul 12, 2021
1 parent af6a783 commit e250a00
Show file tree
Hide file tree
Showing 93 changed files with 1,987 additions and 930 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ apply plugin: 'kotlin-kapt'
apply plugin: "androidx.navigation.safeargs.kotlin"

android {
compileSdkVersion 28
compileSdkVersion 30
defaultConfig {
applicationId "com.raywenderlich.codingcompanionfinder"
minSdkVersion 21
targetSdkVersion 28
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand All @@ -27,17 +27,34 @@ android {
dataBinding {
enabled = true
}

sourceSets {
String sharedTestDir = 'src/sharedTest/java'
String sharedResources = 'src/sharedTest/assets'
test {
java.srcDirs += sharedTestDir
resources.srcDirs += sharedResources
}
androidTest {
java.srcDirs += sharedTestDir
resources.srcDirs += sharedResources
}
}

testOptions {
unitTests.includeAndroidResources = true
unitTests.returnDefaultValues = true
}
}

dependencies {
// android stuff
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.material:material:1.0.0'
implementation "com.android.support:design:28.0.0"
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.legacy:legacy-support-v4:1.0.0'

Expand All @@ -46,48 +63,69 @@ dependencies {
implementation "android.arch.navigation:navigation-fragment-ktx:1.0.0" // use -ktx for

// Glide
implementation("com.github.bumptech.glide:glide:4.8.0") {
implementation("com.github.bumptech.glide:glide:4.12.0") {
exclude group: "com.android.support"
}
kapt 'com.github.bumptech.glide:compiler:4.8.0'
kapt 'com.github.bumptech.glide:compiler:4.12.0'

// carouselview library
implementation "com.synnapps:carouselview:0.1.5"

// retrofit
implementation "com.squareup.okhttp3:logging-interceptor:3.11.0"
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2'
implementation "com.squareup.okhttp3:logging-interceptor:3.14.9"
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'

// eventbus
implementation 'org.greenrobot:eventbus:3.1.1'

// Architecture components
def lifecycle_version = "2.0.0"
def lifecycle_version = "2.2.0"
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
kapt "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"

// Koin
implementation 'org.koin:koin-android-viewmodel:1.0.1'
androidTestImplementation 'org.koin:koin-test:1.0.1'
implementation 'org.koin:koin-android-viewmodel:2.0.1'
androidTestImplementation 'org.koin:koin-test:2.0.1'

// permissions
implementation 'com.karumi:dexter:5.0.0'
implementation 'com.karumi:dexter:6.0.0'

def coroutinesVersion = "1.5.0"

// testing dependencies
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
androidTestImplementation "androidx.test:rules:1.2.0"
androidTestImplementation "androidx.test.ext:junit:1.1.1"
androidTestImplementation "android.arch.navigation:navigation-testing:1.0.0-alpha08"
testImplementation 'junit:junit:4.13.2'
testImplementation 'androidx.test:runner:1.3.0'
testImplementation 'androidx.test.espresso:espresso-core:3.3.0'
testImplementation "androidx.test:rules:1.3.0"
testImplementation "androidx.test.ext:junit:1.1.2"
testImplementation "androidx.navigation:navigation-testing:2.3.5"
testImplementation 'com.squareup.okhttp3:mockwebserver:3.12.0'
testImplementation "androidx.test.espresso:espresso-contrib:3.3.0"
testImplementation 'org.robolectric:robolectric:4.5.1'
testImplementation 'org.koin:koin-test:2.0.1'
testImplementation "androidx.arch.core:core-testing:2.1.0"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion"
testImplementation 'com.github.javafaker:javafaker:0.18'
testImplementation 'androidx.test.espresso:espresso-intents:3.3.0'

// Once https://issuetracker.google.com/127986458 is fixed this can be testImplementation
// fragmentscenario testing
debugImplementation 'androidx.fragment:fragment-testing:1.3.4'
debugImplementation "androidx.test:core:1.3.0"

androidTestImplementation 'androidx.test.espresso:espresso-intents:3.3.0'
androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion"
androidTestImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion"
androidTestImplementation "androidx.arch.core:core-testing:2.1.0"
androidTestImplementation "org.robolectric:annotations:4.5.1"
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
androidTestImplementation "androidx.test:rules:1.3.0"
androidTestImplementation "androidx.test.ext:junit:1.1.2"
androidTestImplementation "androidx.navigation:navigation-testing:2.3.5"
androidTestImplementation 'com.squareup.okhttp3:mockwebserver:3.12.0'
androidTestImplementation "androidx.test.espresso:espresso-contrib:3.2.0"
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.2.0'

// Once https://issuetracker.google.com/127986458 is fixed this can betestImplementation
// fragmentscenario testing
debugImplementation 'androidx.fragment:fragment-testing:1.1.0-rc04'
debugImplementation "androidx.test:core:1.2.0"
androidTestImplementation "androidx.test.espresso:espresso-contrib:3.3.0"
androidTestImplementation 'com.github.javafaker:javafaker:0.18'
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019 Razeware LLC
* Copyright (c) 2021 Razeware LLC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -30,11 +30,21 @@
package com.raywenderlich.codingcompanionfinder

import android.app.Application
import org.koin.android.ext.android.startKoin
import android.util.Log
import org.koin.android.ext.koin.androidContext
import org.koin.core.context.startKoin
import org.koin.core.error.KoinAppAlreadyStartedException

class CodingCompanionFinder: Application(){
class CodingCompanionFinder : Application() {
override fun onCreate() {
super.onCreate()
startKoin(this, listOf(appModule, urlsModule))
try {
startKoin {
androidContext(this@CodingCompanionFinder)
modules(listOf(appModule, urlsModule))
}
} catch (koinAlreadyStartedException: KoinAppAlreadyStartedException) {
Log.i("CodingCompanionFinder", "KoinAppAlreadyStartedException, should only happen in tests")
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019 Razeware LLC
* Copyright (c) 2021 Razeware LLC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019 Razeware LLC
* Copyright (c) 2021 Razeware LLC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -29,22 +29,22 @@
*/
package com.raywenderlich.codingcompanionfinder

import com.jakewharton.retrofit2.adapter.kotlin.coroutines.CoroutineCallAdapterFactory
import com.raywenderlich.codingcompanionfinder.retrofit.AuthorizationInterceptor
import com.raywenderlich.codingcompanionfinder.retrofit.PetFinderService
import com.raywenderlich.codingcompanionfinder.searchforcompanion.SearchForCompanionViewModel
import com.raywenderlich.codingcompanionfinder.searchforcompanion.ViewCompanionViewModel
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import org.koin.android.viewmodel.ext.koin.viewModel
import org.koin.dsl.module.module
import org.koin.android.viewmodel.dsl.viewModel
import org.koin.core.qualifier.named
import org.koin.dsl.module
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import java.util.concurrent.TimeUnit

const val PETFINDER_URL = "PETFINDER_URL"
val urlsModule = module {
single(name = PETFINDER_URL){MainActivity.DEFAULT_PETFINDER_URL}
single(named(PETFINDER_URL)){MainActivity.DEFAULT_PETFINDER_URL}
}
val appModule = module {
single<PetFinderService> {
Expand All @@ -56,9 +56,8 @@ val appModule = module {
.addInterceptor(AuthorizationInterceptor())
.build()
Retrofit.Builder()
.baseUrl(get(PETFINDER_URL) as String)
.baseUrl(get<String>(named(PETFINDER_URL)))
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(CoroutineCallAdapterFactory())
.client(client)
.build().create(PetFinderService::class.java)
}
Expand Down
Loading

0 comments on commit e250a00

Please sign in to comment.