From 77e4e5f0015f2ef8e1f6cd8aae2b181609cd2a2d Mon Sep 17 00:00:00 2001 From: Alex Baker Date: Fri, 25 Oct 2013 10:56:47 -0500 Subject: [PATCH] Update tests * Exclude transitive deps for instrumentTest hack * Convert RepeatAfterCompleteTest to Robolectric --- astrid/build.gradle | 8 +++++-- .../repeats/RepeatAfterCompleteTest.java} | 22 ++++++++++++++----- 2 files changed, 23 insertions(+), 7 deletions(-) rename astrid/src/{instrumentTest/java/com/todoroo/astrid/repeats/RepeatAfterCompleteTests.java => test/java/com/todoroo/astrid/repeats/RepeatAfterCompleteTest.java} (90%) diff --git a/astrid/build.gradle b/astrid/build.gradle index fc9291657..fb0c9f523 100644 --- a/astrid/build.gradle +++ b/astrid/build.gradle @@ -92,6 +92,10 @@ dependencies { testCompile 'junit:junit:4.10' testCompile 'org.robolectric:robolectric:2.3-SNAPSHOT' // hack to get android studio to import libraries - instrumentTestCompile 'junit:junit:4.10' - instrumentTestCompile 'org.robolectric:robolectric:2.3-SNAPSHOT' + instrumentTestCompile('junit:junit:4.10') { + transitive = false + } + instrumentTestCompile('org.robolectric:robolectric:2.3-SNAPSHOT') { + transitive = false + } } diff --git a/astrid/src/instrumentTest/java/com/todoroo/astrid/repeats/RepeatAfterCompleteTests.java b/astrid/src/test/java/com/todoroo/astrid/repeats/RepeatAfterCompleteTest.java similarity index 90% rename from astrid/src/instrumentTest/java/com/todoroo/astrid/repeats/RepeatAfterCompleteTests.java rename to astrid/src/test/java/com/todoroo/astrid/repeats/RepeatAfterCompleteTest.java index 69c906cfa..08102dd96 100644 --- a/astrid/src/instrumentTest/java/com/todoroo/astrid/repeats/RepeatAfterCompleteTests.java +++ b/astrid/src/test/java/com/todoroo/astrid/repeats/RepeatAfterCompleteTest.java @@ -9,23 +9,33 @@ import com.google.ical.values.Frequency; import com.google.ical.values.RRule; import com.google.ical.values.Weekday; import com.google.ical.values.WeekdayNum; -import com.todoroo.andlib.test.TodorooTestCase; +import com.todoroo.andlib.test.TodorooRobolectricTestCase; import com.todoroo.andlib.utility.DateUtilities; import com.todoroo.astrid.data.Task; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.robolectric.RobolectricTestRunner; + import java.text.ParseException; import java.util.ArrayList; import java.util.Date; import java.util.TimeZone; -public class RepeatAfterCompleteTests extends TodorooTestCase { +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +@RunWith(RobolectricTestRunner.class) +public class RepeatAfterCompleteTest extends TodorooRobolectricTestCase { private Task task; private long nextDueDate; private RRule rrule; - @Override - protected void setUp() throws Exception { + @Before + public void setUp() throws Exception { super.setUp(); task = new Task(); task.setValue(Task.COMPLETION_DATE, DateUtilities.now()); @@ -34,6 +44,7 @@ public class RepeatAfterCompleteTests extends TodorooTestCase { // --- date with time tests + @Test public void testSubDailyFreqs() throws ParseException { task.setValue(Task.DUE_DATE, DateUtilities.now() - DateUtilities.ONE_WEEK); @@ -59,6 +70,7 @@ public class RepeatAfterCompleteTests extends TodorooTestCase { } } + @Test public void testDailyAndGreaterFreqs() throws ParseException { task.setValue(Task.DUE_DATE, Task.createDueDate(Task.URGENCY_SPECIFIC_DAY, @@ -89,6 +101,7 @@ public class RepeatAfterCompleteTests extends TodorooTestCase { } } + @Test public void testTimeZoneLate() throws ParseException { TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles")); task.setValue(Task.DUE_DATE, DateUtilities.now() + DateUtilities.ONE_WEEK); @@ -127,5 +140,4 @@ public class RepeatAfterCompleteTests extends TodorooTestCase { days.add(new WeekdayNum(0, wd)); rrule.setByDay(days); } - }