Skip to content

Instantly share code, notes, and snippets.

Avatar

Thomas Cirksena grumpyshoe

  • Oldenburg, Germany
View GitHub Profile
@grumpyshoe
grumpyshoe / Gradle: Invalidate dependencies
Created Sep 26, 2019
invalidate gradle dependecies for test purpose
View Gradle: Invalidate dependencies
# https://stackoverflow.com/questions/13565082/how-can-i-force-gradle-to-redownload-dependencies
# https://discuss.gradle.org/t/how-to-get-gradle-to-download-newer-snapshots-to-gradle-cache-when-using-an-ivy-repository/7344
# You can tell Gradle to re-download some dependencies in the build script by flagging
# the dependency as 'changing'. Gradle will then check for updates every 24 hours, but
# this can be configured using the resolutionStrategy DSL. I find it useful to use this
# for for SNAPSHOT or NIGHTLY builds.
configurations.all {
// Check for updates every build
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
@grumpyshoe
grumpyshoe / build.gradle
Created Mar 11, 2019
Gradle: how to get git hash in build.gradle
View build.gradle
String getGitHash() {
// git hash
def command = Runtime.getRuntime().exec("git rev-parse --short HEAD")
def result = command.waitFor()
if (result != 0) {
throw new IOException("Command 'getGitHash()' exited with " + result)
}
String gitCommitHash = command.inputStream.text.trim()
View MainViewTest.kt
class MainViewTest {
@Rule
@JvmField
var testRule = IntentsTestRule(MainActivity::class.java, true, false)
// nedded for correct handling of 'postValue' in LiveData
@Rule
@JvmField
var rule: TestRule = InstantTaskExecutorRule()
@grumpyshoe
grumpyshoe / TestApplication.kt
Last active Jan 18, 2019
Example of custom Application class containing values for mocking UI-Test-components
View TestApplication.kt
class TestAppApplication : Application() {
// initialize mock ApiService
var mockApiService = MockApiService
/**
* onCreate
*
*/
override fun onCreate() {
@grumpyshoe
grumpyshoe / MockApiService.kt
Last active Jan 18, 2019
Example of mocked Dagger injection for UI-Test
View MockApiService.kt
object MockApiService {
// all available methods
enum class Method {
getData
}
// expatiations
private val expectationMap = mutableMapOf<Method, Expectation>()
@grumpyshoe
grumpyshoe / build.gradle
Created Jan 18, 2019
How to use custom TestRunner
View build.gradle
android {
...
defaultConfig {
  ...
testInstrumentationRunner "com.grumpyshoe.myapplication.core.MockTestRunner"
...
}
...
}
@grumpyshoe
grumpyshoe / MockTestRunner.kt
Last active Jan 18, 2019
TestRunner using custom Application implementation
View MockTestRunner.kt
open class MockTestRunner : AndroidJUnitRunner() {
override fun onCreate(arguments: Bundle) {
StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder().permitAll().build())
super.onCreate(arguments)
}
@Throws(InstantiationException::class, IllegalAccessException::class, ClassNotFoundException::class)
override fun newApplication(cl: ClassLoader, className: String, context: Context): Application {
View MainViewModelTest.kt
class MainViewModelTest {
private lateinit var apiService: ApiService
@Rule
@JvmField
var rule: TestRule = InstantTaskExecutorRule()
@Before
fun setUp() {
@grumpyshoe
grumpyshoe / osx_animations.sh
Created Jan 8, 2018 — forked from dvdrhr/osx_animations.sh
osx animation options
View osx_animations.sh
# opening and closing windows and popovers
defaults write -g NSAutomaticWindowAnimationsEnabled -bool false
# smooth scrolling
defaults write -g NSScrollAnimationEnabled -bool false
# showing and hiding sheets, resizing preference windows, zooming windows
# float 0 doesn't work
defaults write -g NSWindowResizeTime -float 0.001
@grumpyshoe
grumpyshoe / gist:d2c324303b382d4aa75adb0c0f822a62
Created Feb 9, 2017
Android / Espresso / Spinner - How to click on a spinner item
View gist:d2c324303b382d4aa75adb0c0f822a62
onView(withId(R.id.spinner)).perform(click());
onView(allOf(withId(R.id.textview_in_custom_spinner), withText("DummyText"))).perform(click());