mirror of
https://github.com/moparisthebest/k-9
synced 2024-11-23 09:52:16 -05:00
Merge pull request #652 from k9mail/gradle_unit_test_support
Gradle unit test support
This commit is contained in:
commit
270d22681f
@ -4,7 +4,7 @@ buildscript {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:1.0.0'
|
||||
classpath 'com.android.tools.build:gradle:1.2.3'
|
||||
classpath 'com.jakewharton.sdkmanager:gradle-plugin:0.12.0'
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<lint>
|
||||
<issue id="MissingTranslation" severity="ignore" />
|
||||
<issue id="OldTargetApi" severity="ignore" />
|
||||
|
||||
<!-- Transifex and Lint disagree on what quantities are necessary -->
|
||||
<issue id="UnusedQuantity" severity="warning">
|
||||
|
@ -1,14 +1,29 @@
|
||||
apply plugin: 'findbugs'
|
||||
|
||||
check.dependsOn 'findbugs'
|
||||
task findbugs(type: FindBugs, dependsOn: ['compileDebugJava', 'compileDebugTestJava']) {
|
||||
ignoreFailures = true
|
||||
classes = fileTree('build/intermediates/classes/debug/') +
|
||||
fileTree('build/intermediates/classes/test/debug/')
|
||||
source = project.android.sourceSets.main.java.getSrcDirs() +
|
||||
project.android.sourceSets.androidTest.java.getSrcDirs()
|
||||
classpath = files()
|
||||
effort = 'max'
|
||||
includeFilter = file("$rootProject.projectDir/config/findbugs/include_filter.xml")
|
||||
excludeFilter = file("$rootProject.projectDir/config/findbugs/exclude_filter.xml")
|
||||
afterEvaluate {
|
||||
def variants = plugins.hasPlugin('com.android.application') ?
|
||||
android.applicationVariants : android.libraryVariants
|
||||
|
||||
variants.each { variant ->
|
||||
def task = project.task("findBugs${variant.name.capitalize()}", type: FindBugs) {
|
||||
group = 'verification'
|
||||
description = "Run FindBugs for the ${variant.description}."
|
||||
|
||||
effort = 'max'
|
||||
ignoreFailures = true
|
||||
|
||||
includeFilter = file("$rootProject.projectDir/config/findbugs/include_filter.xml")
|
||||
excludeFilter = file("$rootProject.projectDir/config/findbugs/exclude_filter.xml")
|
||||
|
||||
def variantCompile = variant.javaCompile
|
||||
|
||||
classes = fileTree(variantCompile.destinationDir)
|
||||
source = variantCompile.source
|
||||
classpath = variantCompile.classpath.plus(project.files(android.bootClasspath))
|
||||
|
||||
dependsOn(variantCompile)
|
||||
}
|
||||
|
||||
tasks.getByName('check').dependsOn(task)
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply from: '../gradle/plugins/checkstyle-android.gradle'
|
||||
apply from: '../gradle/plugins/findbugs-android.gradle'
|
||||
apply plugin: 'jacoco'
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
@ -12,6 +13,17 @@ dependencies {
|
||||
compile 'commons-io:commons-io:2.4'
|
||||
compile 'com.jcraft:jzlib:1.0.7'
|
||||
compile 'com.beetstra.jutf7:jutf7:1.0.0'
|
||||
|
||||
androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
|
||||
androidTestCompile 'com.madgag.spongycastle:pg:1.51.0.0'
|
||||
|
||||
testCompile('org.robolectric:robolectric:3.0-rc3') {
|
||||
exclude group: 'org.hamcrest', module: 'hamcrest-core'
|
||||
}
|
||||
testCompile 'org.hamcrest:hamcrest-core:1.3'
|
||||
testCompile('junit:junit:4.10') {
|
||||
exclude group: 'org.hamcrest', module: 'hamcrest-core'
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
@ -21,6 +33,14 @@ android {
|
||||
defaultConfig {
|
||||
minSdkVersion 15
|
||||
targetSdkVersion 21
|
||||
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
debug {
|
||||
testCoverageEnabled rootProject.testCoverage
|
||||
}
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
@ -40,5 +60,6 @@ android {
|
||||
exclude 'META-INF/LICENSE.txt'
|
||||
exclude 'META-INF/NOTICE'
|
||||
exclude 'META-INF/NOTICE.txt'
|
||||
exclude 'LICENSE.txt'
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,15 @@ package com.fsck.k9.mail;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(manifest = Config.NONE)
|
||||
public class AddressTest {
|
||||
/**
|
||||
* test the possibility to parse "From:" fields with no email.
|
@ -2,10 +2,15 @@ package com.fsck.k9.mail;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(manifest = Config.NONE)
|
||||
public class Address_quoteAtoms {
|
||||
@Test
|
||||
public void testNoQuote() {
|
@ -2,10 +2,15 @@ package com.fsck.k9.mail.internet;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(manifest = Config.NONE)
|
||||
public class CharsetSupportTest {
|
||||
|
||||
@Test
|
@ -2,10 +2,15 @@ package com.fsck.k9.mail.internet;
|
||||
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(manifest = Config.NONE)
|
||||
public class DecoderUtilTest {
|
||||
|
||||
@Test
|
@ -18,10 +18,15 @@ import com.fsck.k9.mail.Body;
|
||||
import com.fsck.k9.mail.BodyPart;
|
||||
import com.fsck.k9.mail.Message.RecipientType;
|
||||
import com.fsck.k9.mail.Multipart;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(manifest = Config.NONE)
|
||||
public class MimeMessageParseTest {
|
||||
@Before
|
||||
public void setup() {
|
@ -3,6 +3,9 @@ package com.fsck.k9.mail.store.imap;
|
||||
import com.fsck.k9.mail.filter.PeekableInputStream;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
@ -16,6 +19,8 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(manifest = Config.NONE)
|
||||
public class ImapResponseParserTest {
|
||||
|
||||
@Test public void testSimpleOkResponse() throws IOException {
|
@ -18,12 +18,17 @@
|
||||
package com.fsck.k9.mail.store.imap;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(manifest = Config.NONE)
|
||||
public class ImapUtilityTest {
|
||||
@Test
|
||||
public void testGetImapSequenceValues() {
|
@ -2,6 +2,7 @@ apply plugin: 'android-sdk-manager'
|
||||
apply plugin: 'com.android.application'
|
||||
apply from: '../gradle/plugins/checkstyle-android.gradle'
|
||||
apply from: '../gradle/plugins/findbugs-android.gradle'
|
||||
apply plugin: 'jacoco'
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
@ -24,7 +25,14 @@ dependencies {
|
||||
androidTestCompile('com.icegreen:greenmail:1.4.1') {
|
||||
exclude group: 'junit'
|
||||
}
|
||||
androidTestCompile 'com.madgag.spongycastle:pg:1.51.0.0'
|
||||
|
||||
testCompile('org.robolectric:robolectric:3.0-rc3') {
|
||||
exclude group: 'org.hamcrest', module: 'hamcrest-core'
|
||||
}
|
||||
testCompile 'org.hamcrest:hamcrest-core:1.3'
|
||||
testCompile('junit:junit:4.10') {
|
||||
exclude group: 'org.hamcrest', module: 'hamcrest-core'
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
|
@ -1,12 +1,12 @@
|
||||
package com.fsck.k9.activity;
|
||||
|
||||
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.fsck.k9.mail.Flag;
|
||||
import com.fsck.k9.mail.MessagingException;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
@ -14,7 +14,8 @@ import static junit.framework.Assert.assertNull;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(manifest = Config.NONE)
|
||||
public class MessageReferenceTest {
|
||||
|
||||
@Test
|
@ -3,8 +3,6 @@ package com.fsck.k9.crypto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import com.fsck.k9.mail.Part;
|
||||
import com.fsck.k9.mail.internet.MimeBodyPart;
|
||||
import com.fsck.k9.mail.internet.MimeMessage;
|
||||
@ -13,12 +11,15 @@ import com.fsck.k9.mail.internet.MimeMultipart;
|
||||
import com.fsck.k9.mail.internet.TextBody;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertSame;
|
||||
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(manifest = Config.NONE)
|
||||
public class MessageDecryptVerifierTest {
|
||||
|
||||
@Test
|
@ -1,18 +1,20 @@
|
||||
package com.fsck.k9.helper;
|
||||
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(manifest = Config.NONE)
|
||||
public class HtmlConverterTest {
|
||||
// Useful if you want to write stuff to a file for debugging in a browser.
|
||||
private static final boolean WRITE_TO_FILE = Boolean.parseBoolean(System.getProperty("k9.htmlConverterTest.writeToFile", "false"));
|
@ -3,27 +3,29 @@ package com.fsck.k9.helper;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.text.SpannableString;
|
||||
|
||||
import com.fsck.k9.mail.Address;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
@Config(manifest = Config.NONE)
|
||||
public class MessageHelperTest {
|
||||
private Contacts contacts;
|
||||
private Contacts mockContacts;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
Context context = InstrumentationRegistry.getTargetContext();
|
||||
Context context = RuntimeEnvironment.application;
|
||||
contacts = new Contacts(context);
|
||||
mockContacts = new Contacts(context) {
|
||||
@Override public String getNameForAddress(String address) {
|
@ -3,6 +3,7 @@ package com.fsck.k9.message;
|
||||
import com.fsck.k9.Account.QuoteStyle;
|
||||
import com.fsck.k9.mail.internet.TextBody;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.experimental.theories.DataPoints;
|
||||
import org.junit.experimental.theories.Theories;
|
||||
import org.junit.experimental.theories.Theory;
|
||||
@ -12,6 +13,8 @@ import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
//TODO: Get rid of 'Theories' and write simple tests
|
||||
@Ignore
|
||||
@RunWith(Theories.class)
|
||||
public class TextBodyBuilderTest {
|
||||
|
@ -3,4 +3,3 @@ include ':k9mail-library'
|
||||
include ':plugins:Android-PullToRefresh:library'
|
||||
include ':plugins:HoloColorPicker'
|
||||
include ':plugins:openpgp-api-library'
|
||||
include ':tests-on-jvm'
|
||||
|
@ -1,39 +0,0 @@
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'findbugs'
|
||||
apply plugin: 'checkstyle'
|
||||
apply plugin: 'jacoco'
|
||||
|
||||
dependencies {
|
||||
testCompile project(':k9mail')
|
||||
testCompile 'junit:junit:4.12'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
test {
|
||||
compileClasspath += files(project(':k9mail').compileDebugJava.destinationDir)
|
||||
compileClasspath += project(':k9mail').compileDebugJava.classpath
|
||||
runtimeClasspath += files(project(':k9mail').compileDebugJava.destinationDir)
|
||||
runtimeClasspath += project(':k9mail').compileDebugJava.classpath
|
||||
}
|
||||
}
|
||||
|
||||
checkstyle {
|
||||
ignoreFailures = true
|
||||
configFile file("$rootProject.projectDir/config/checkstyle/checkstyle.xml")
|
||||
}
|
||||
|
||||
findbugs {
|
||||
ignoreFailures = true
|
||||
effort = 'max'
|
||||
includeFilter = file("$rootProject.projectDir/config/findbugs/include_filter.xml")
|
||||
excludeFilter = file("$rootProject.projectDir/config/findbugs/exclude_filter.xml")
|
||||
}
|
||||
|
||||
check.dependsOn 'checkstyleTest'
|
||||
check.dependsOn 'findbugsTest'
|
||||
|
||||
compileTestJava.dependsOn ':k9mail:compileDebugJava'
|
@ -1,7 +0,0 @@
|
||||
package android.text;
|
||||
|
||||
public class TextUtils {
|
||||
public static boolean isEmpty(CharSequence str) {
|
||||
return (str == null || str.length() == 0);
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package android.util;
|
||||
|
||||
public class Log {
|
||||
public static int v(String tag, String message) { return 0; }
|
||||
public static int d(String tag, String message) { return 0; }
|
||||
public static int d(String tag, String message, Throwable throwable) { return 0; }
|
||||
public static int i(String tag, String message) { return 0; }
|
||||
public static int w(String tag, String message) { return 0; }
|
||||
public static int e(String tag, String message) { return 0; }
|
||||
public static int e(String tag, String message, Throwable th) { return 0; }
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
package com.fsck.k9;
|
||||
|
||||
public class K9 {
|
||||
public static boolean DEBUG = false;
|
||||
}
|
Loading…
Reference in New Issue
Block a user