Skip to content

Commit

Permalink
Update robolectric, use Runner class instead of annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominik Schürmann committed Feb 5, 2017
1 parent 1c1be7f commit 1813510
Show file tree
Hide file tree
Showing 42 changed files with 117 additions and 139 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Expand Up @@ -2,7 +2,7 @@ androidCompileSdkVersion=24
androidBuildToolsVersion=24.0.3
androidSupportLibraryVersion=23.1.1

robolectricVersion=3.1.1
robolectricVersion=3.2.2
junitVersion=4.12
mockitoVersion=1.10.19
okioVersion=1.11.0
20 changes: 20 additions & 0 deletions k9mail/src/test/java/com/fsck/k9/K9RobolectricTestRunner.java
@@ -0,0 +1,20 @@
package com.fsck.k9;

import org.junit.runners.model.InitializationError;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

public class K9RobolectricTestRunner extends RobolectricTestRunner {

public K9RobolectricTestRunner(Class<?> testClass) throws InitializationError {
super(testClass);
}

@Override
protected Config buildGlobalConfig() {
return new Config.Builder()
.setSdk(21)
.setManifest("src/main/AndroidManifest.xml")
.build();
}
}
Expand Up @@ -4,6 +4,7 @@
import android.content.Context;

import com.fsck.k9.Account;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.mail.Message;
import org.junit.Before;
import org.junit.Test;
Expand All @@ -17,8 +18,7 @@
import static org.mockito.Mockito.when;


@RunWith(RobolectricTestRunner.class)
@Config(manifest = "src/main/AndroidManifest.xml", sdk = 21)
@RunWith(K9RobolectricTestRunner.class)
public class ActivityListenerTest {
private static final String FOLDER = "folder";
private static final String ERROR_MESSAGE = "errorMessage";
Expand Down
@@ -1,10 +1,10 @@
package com.fsck.k9.activity;


import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.mail.Flag;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

import static junit.framework.Assert.assertEquals;
Expand All @@ -14,8 +14,8 @@
import static org.junit.Assert.assertNotNull;


@RunWith(RobolectricTestRunner.class)
@Config(manifest = Config.NONE, sdk = 21)
@RunWith(K9RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
public class MessageReferenceTest {

@Test
Expand Down
Expand Up @@ -10,6 +10,7 @@
import android.os.ParcelFileDescriptor;

import com.fsck.k9.Account;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.activity.compose.RecipientMvpView.CryptoSpecialModeDisplayType;
import com.fsck.k9.activity.compose.RecipientMvpView.CryptoStatusDisplayType;
import com.fsck.k9.activity.compose.RecipientPresenter.CryptoMode;
Expand All @@ -28,7 +29,6 @@
import org.openintents.openpgp.util.OpenPgpServiceConnection;
import org.openintents.openpgp.util.ShadowOpenPgpAsyncTask;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowApplication;

Expand All @@ -43,8 +43,8 @@
import static org.mockito.Mockito.when;


@RunWith(RobolectricTestRunner.class)
@Config(manifest = "src/main/AndroidManifest.xml", sdk = 21, shadows = {ShadowOpenPgpAsyncTask.class})
@RunWith(K9RobolectricTestRunner.class)
@Config(shadows = {ShadowOpenPgpAsyncTask.class})
public class RecipientPresenterTest {
private static final ReplyToAddresses TO_ADDRESSES = new ReplyToAddresses(Address.parse("to@example.org"));
private static final List<Address> ALL_TO_ADDRESSES = Arrays.asList(Address.parse("allTo@example.org"));
Expand Down
@@ -1,6 +1,7 @@
package com.fsck.k9.cache;


import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.mailstore.LocalFolder;
import com.fsck.k9.mailstore.LocalMessage;

Expand All @@ -9,9 +10,7 @@
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;

import java.util.Collections;
import java.util.UUID;
Expand All @@ -25,8 +24,7 @@
import static org.mockito.Mockito.when;


@RunWith(RobolectricTestRunner.class)
@Config(manifest = "src/main/AndroidManifest.xml", sdk = 21)
@RunWith(K9RobolectricTestRunner.class)
public class EmailProviderCacheTest {

private EmailProviderCache cache;
Expand Down
Expand Up @@ -13,6 +13,7 @@

import com.fsck.k9.Account;
import com.fsck.k9.AccountStats;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.Preferences;
import com.fsck.k9.helper.Contacts;
import com.fsck.k9.mail.FetchProfile;
Expand All @@ -38,8 +39,6 @@
import org.mockito.MockitoAnnotations;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowApplication;

import static org.junit.Assert.assertEquals;
Expand All @@ -60,8 +59,7 @@


@SuppressWarnings("unchecked")
@RunWith(RobolectricTestRunner.class)
@Config(manifest = "src/main/AndroidManifest.xml", sdk = 21)
@RunWith(K9RobolectricTestRunner.class)
public class MessagingControllerTest {
private static final String FOLDER_NAME = "Folder";
private static final int MAXIMUM_SMALL_MESSAGE_SIZE = 1000;
Expand Down
Expand Up @@ -4,6 +4,7 @@
import java.util.ArrayList;
import java.util.List;

import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.mail.BodyPart;
import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.MessagingException;
Expand All @@ -18,7 +19,6 @@
import com.fsck.k9.ui.crypto.MessageCryptoAnnotations;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

import static org.junit.Assert.assertEquals;
Expand All @@ -29,8 +29,8 @@
import static org.mockito.Mockito.mock;


@RunWith(RobolectricTestRunner.class)
@Config(manifest = Config.NONE, sdk = 21)
@RunWith(K9RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
public class MessageDecryptVerifierTest {
private static final String MIME_TYPE_MULTIPART_ENCRYPTED = "multipart/encrypted";
private MessageCryptoAnnotations messageCryptoAnnotations = mock(MessageCryptoAnnotations.class);
Expand Down
Expand Up @@ -2,16 +2,16 @@


import com.fsck.k9.Identity;
import com.fsck.k9.K9RobolectricTestRunner;

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, sdk = 21)
@RunWith(K9RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
public class OpenPgpApiHelperTest {

@Test
Expand Down
6 changes: 3 additions & 3 deletions k9mail/src/test/java/com/fsck/k9/helper/MailToTest.java
Expand Up @@ -7,13 +7,13 @@

import android.net.Uri;

import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.helper.MailTo.CaseInsensitiveParamWrapper;
import com.fsck.k9.mail.Address;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

import static junit.framework.Assert.assertEquals;
Expand All @@ -23,8 +23,8 @@
import static org.junit.Assert.assertThat;


@RunWith(RobolectricTestRunner.class)
@Config(manifest = Config.NONE, sdk = 21)
@RunWith(K9RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
public class MailToTest {
@Rule
public ExpectedException exception = ExpectedException.none();
Expand Down
Expand Up @@ -5,20 +5,20 @@
import android.graphics.Color;
import android.text.SpannableString;

import com.fsck.k9.K9RobolectricTestRunner;
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(RobolectricTestRunner.class)
@Config(manifest = Config.NONE, sdk = 21)
@RunWith(K9RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
public class MessageHelperTest {
private Contacts contacts;
private Contacts mockContacts;
Expand Down
Expand Up @@ -5,6 +5,7 @@
import java.util.ArrayList;

import com.fsck.k9.Account;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.helper.ReplyToParser.ReplyToAddresses;
import com.fsck.k9.mail.Address;
import com.fsck.k9.mail.Message;
Expand All @@ -13,7 +14,6 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

import static org.junit.Assert.assertArrayEquals;
Expand All @@ -26,8 +26,8 @@
import static org.mockito.Mockito.when;


@RunWith(RobolectricTestRunner.class)
@Config(manifest = Config.NONE, sdk = 21)
@RunWith(K9RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
public class ReplyToParserTest {
private static final Address[] REPLY_TO_ADDRESSES = Address.parse("replyTo1@example.com, replyTo2@example.com");
private static final Address[] LIST_POST_ADDRESSES = Address.parse("listPost@example.com");
Expand Down
Expand Up @@ -5,6 +5,7 @@

import android.net.Uri;

import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.mail.BodyPart;
import com.fsck.k9.mail.Multipart;
import com.fsck.k9.mail.Part;
Expand All @@ -15,7 +16,6 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

import static org.junit.Assert.*;
Expand All @@ -26,8 +26,8 @@


@SuppressWarnings("unchecked")
@RunWith(RobolectricTestRunner.class)
@Config(manifest = Config.NONE, sdk = 21)
@RunWith(K9RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
public class AttachmentResolverTest {
public static final Uri ATTACHMENT_TEST_URI_1 = Uri.parse("uri://test/1");
public static final Uri ATTACHMENT_TEST_URI_2 = Uri.parse("uri://test/2");
Expand Down
Expand Up @@ -7,25 +7,24 @@
import java.io.InputStream;
import java.io.OutputStream;

import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.mailstore.util.FileFactory;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.fail;


@RunWith(RobolectricTestRunner.class)
@Config(manifest = Config.NONE, sdk = 21)
@RunWith(K9RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
public class DeferredFileBodyTest {
public static final String TEST_ENCODING = "test-encoding";
public static final byte[] TEST_DATA_SHORT = "test data".getBytes();
Expand Down
Expand Up @@ -11,6 +11,7 @@
import android.app.Application;

import com.fsck.k9.GlobalsHelper;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.activity.K9ActivityCommon;
import com.fsck.k9.message.html.HtmlSanitizer;
import com.fsck.k9.message.html.HtmlSanitizerHelper;
Expand All @@ -31,9 +32,7 @@
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.assertSame;
Expand All @@ -42,8 +41,7 @@
import static org.mockito.Mockito.when;


@RunWith(RobolectricTestRunner.class)
@Config(manifest = "src/main/AndroidManifest.xml", sdk = 21)
@RunWith(K9RobolectricTestRunner.class)
public class MessageViewInfoExtractorTest {
public static final String BODY_TEXT = "K-9 Mail rocks :>";
public static final String BODY_TEXT_HTML = "K-9 Mail rocks :&gt;";
Expand Down
6 changes: 2 additions & 4 deletions k9mail/src/test/java/com/fsck/k9/mailstore/MigrationTest.java
Expand Up @@ -14,6 +14,7 @@

import com.fsck.k9.Account;
import com.fsck.k9.K9;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.Preferences;
import com.fsck.k9.mail.BodyPart;
import com.fsck.k9.mail.FetchProfile;
Expand All @@ -28,14 +29,11 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openintents.openpgp.util.OpenPgpUtils;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowLog;
import org.robolectric.shadows.ShadowSQLiteConnection;

@RunWith(RobolectricTestRunner.class)
@Config(manifest = "src/main/AndroidManifest.xml", sdk = 21)
@RunWith(K9RobolectricTestRunner.class)
public class MigrationTest {

Account account;
Expand Down

0 comments on commit 1813510

Please sign in to comment.