Skip to content

Instantly share code, notes, and snippets.

@t-kashima
Last active August 29, 2015 14:26
Show Gist options
  • Save t-kashima/2fca22ef2babf6b818fe to your computer and use it in GitHub Desktop.
Save t-kashima/2fca22ef2babf6b818fe to your computer and use it in GitHub Desktop.
JUnit4を使ったテスト
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.unuuu.myapp"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'LICENSE.txt'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
}
package com.unuuu.myapp;
import android.support.test.runner.AndroidJUnit4;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
@RunWith(AndroidJUnit4.class)
public class MainActivityTest {
@Before
public void setUp() throws Exception {
}
@Test
public void テストのテスト() {
assertThat("hoge", is("hoge"));
}
@After
public void tearDown() throws Exception {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment