Added testing framework for local unit tests and instrumented unit tests

pull/282/head
Loren M. Lang 2020-08-30 15:44:38 -07:00
rodzic 52a63a489f
commit a27ac7c32e
3 zmienionych plików z 50 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,26 @@
package org.aprsdroid.app;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("org.aprsdroid.app", appContext.getPackageName());
}
}

Wyświetl plik

@ -69,6 +69,7 @@ def mapsApiKey() {
android {
compileSdkVersion 28
buildToolsVersion "28.0.3"
defaultConfig {
minSdkVersion 14
targetSdkVersion 28
@ -79,6 +80,8 @@ android {
resValue "string", "build_version", "$build_version"
resValue "string", "google_maps_key", mapsApiKey()
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
useLibrary 'org.apache.http.legacy'
compileOptions {
@ -127,6 +130,12 @@ android {
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs']
}
androidTest {
java.srcDirs = ['androidTest/java']
}
test {
java.srcDirs = ['test/java']
}
}
lintOptions {
disable 'MissingTranslation'
@ -147,4 +156,7 @@ dependencies {
implementation 'com.google.maps.android:android-maps-utils:0.5'
implementation 'com.squareup.okio:okio:2.1.0'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
testImplementation 'junit:junit:4.12'
}

Wyświetl plik

@ -0,0 +1,12 @@
package org.aprsdroid.app;
import org.junit.Test;
import static org.junit.Assert.*;
public class AprsPacketTests {
@Test
public void testBasic() {
assertEquals(18403, AprsPacket.passcode("AB1CD"));
}
}