Created
January 26, 2018 09:26
-
-
Save MaksimDmitriev/1ceea5c08abb5fa9dc485fce7f71f630 to your computer and use it in GitHub Desktop.
Revisions
-
MaksimDmitriev created this gist
Jan 26, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ package sample.com.sample_app; import android.support.annotation.NonNull; public class FileUtils { @NonNull public static String generateName() { return Long.toString(System.currentTimeMillis()); } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ package sample.com.sample_app; import org.junit.Test; import org.junit.runner.RunWith; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import static junit.framework.TestCase.assertEquals; @RunWith(PowerMockRunner.class) @PrepareForTest({System.class}) public class FileUtilsTest { @Test public void generateName() { PowerMockito.spy(System.class); PowerMockito.when(System.currentTimeMillis()).thenReturn(100L); String name = FileUtils.generateName(); assertEquals("100", name); } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ apply plugin: 'com.android.application' android { compileSdkVersion 26 defaultConfig { applicationId "sample.com.sample_app" minSdkVersion 15 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support.constraint:constraint-layout:1.0.2' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1' testImplementation 'org.mockito:mockito-core:2.8.9' String powerMockVersion = "1.7.3" testImplementation "org.powermock:powermock-module-junit4:${powerMockVersion}" testImplementation "org.powermock:powermock-api-mockito2:${powerMockVersion}" }