mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 01:08:50 -06:00
Move command tests to JVM
This commit is contained in:
@@ -71,6 +71,7 @@ dependencies {
|
||||
compile project(':libs:drag-sort-listview:library')
|
||||
|
||||
testCompile 'junit:junit:4.12'
|
||||
testCompile 'org.hamcrest:hamcrest-library:1.3'
|
||||
testCompile 'org.mockito:mockito-core:1.10.19'
|
||||
|
||||
androidTestCompile 'com.android.support:support-annotations:23.3.0'
|
||||
|
||||
@@ -17,31 +17,23 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.isoron.uhabits.unit.commands;
|
||||
package org.isoron.uhabits.commands;
|
||||
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
import org.isoron.uhabits.*;
|
||||
import org.isoron.uhabits.models.*;
|
||||
import org.junit.*;
|
||||
|
||||
import org.isoron.uhabits.BaseAndroidTest;
|
||||
import org.isoron.uhabits.commands.ArchiveHabitsCommand;
|
||||
import org.isoron.uhabits.models.Habit;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import java.util.*;
|
||||
|
||||
import java.util.Collections;
|
||||
import static junit.framework.Assert.*;
|
||||
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@SmallTest
|
||||
public class ArchiveHabitsCommandTest extends BaseAndroidTest
|
||||
public class ArchiveHabitsCommandTest extends BaseUnitTest
|
||||
{
|
||||
|
||||
private ArchiveHabitsCommand command;
|
||||
private Habit habit;
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp()
|
||||
{
|
||||
@@ -17,30 +17,24 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.isoron.uhabits.unit.commands;
|
||||
package org.isoron.uhabits.commands;
|
||||
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
import org.isoron.uhabits.*;
|
||||
import org.isoron.uhabits.models.*;
|
||||
import org.junit.*;
|
||||
|
||||
import org.isoron.uhabits.BaseAndroidTest;
|
||||
import org.isoron.uhabits.commands.ChangeHabitColorCommand;
|
||||
import org.isoron.uhabits.models.Habit;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import java.util.*;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@SmallTest
|
||||
public class ChangeHabitColorCommandTest extends BaseAndroidTest
|
||||
public class ChangeHabitColorCommandTest extends BaseUnitTest
|
||||
{
|
||||
private ChangeHabitColorCommand command;
|
||||
|
||||
private LinkedList<Habit> habits;
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp()
|
||||
{
|
||||
@@ -48,7 +42,7 @@ public class ChangeHabitColorCommandTest extends BaseAndroidTest
|
||||
|
||||
habits = new LinkedList<>();
|
||||
|
||||
for(int i = 0; i < 3; i ++)
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
Habit habit = fixtures.createShortHabit();
|
||||
habit.setColor(i + 1);
|
||||
@@ -73,16 +67,16 @@ public class ChangeHabitColorCommandTest extends BaseAndroidTest
|
||||
checkNewColors();
|
||||
}
|
||||
|
||||
private void checkNewColors()
|
||||
{
|
||||
for (Habit h : habits)
|
||||
assertThat(h.getColor(), equalTo(0));
|
||||
}
|
||||
|
||||
private void checkOriginalColors()
|
||||
{
|
||||
int k = 0;
|
||||
for(Habit h : habits)
|
||||
for (Habit h : habits)
|
||||
assertThat(h.getColor(), equalTo(++k));
|
||||
}
|
||||
|
||||
private void checkNewColors()
|
||||
{
|
||||
for(Habit h : habits)
|
||||
assertThat(h.getColor(), equalTo(0));
|
||||
}
|
||||
}
|
||||
@@ -17,33 +17,26 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.isoron.uhabits.unit.commands;
|
||||
package org.isoron.uhabits.commands;
|
||||
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
import org.isoron.uhabits.*;
|
||||
import org.isoron.uhabits.models.*;
|
||||
import org.junit.*;
|
||||
|
||||
import org.isoron.uhabits.BaseAndroidTest;
|
||||
import org.isoron.uhabits.commands.CreateHabitCommand;
|
||||
import org.isoron.uhabits.models.Habit;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import java.util.*;
|
||||
|
||||
import java.util.List;
|
||||
import static junit.framework.Assert.*;
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@SmallTest
|
||||
public class CreateHabitCommandTest extends BaseAndroidTest
|
||||
public class CreateHabitCommandTest extends BaseUnitTest
|
||||
{
|
||||
|
||||
private CreateHabitCommand command;
|
||||
|
||||
private Habit model;
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp()
|
||||
{
|
||||
@@ -52,8 +45,7 @@ public class CreateHabitCommandTest extends BaseAndroidTest
|
||||
model = new Habit();
|
||||
model.setName("New habit");
|
||||
command = new CreateHabitCommand(model);
|
||||
|
||||
fixtures.purgeHabits(habitList);
|
||||
fixtures.purgeHabits();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -82,4 +74,6 @@ public class CreateHabitCommandTest extends BaseAndroidTest
|
||||
assertThat(id, equalTo(newId));
|
||||
assertThat(habit.getName(), equalTo(model.getName()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -17,26 +17,19 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.isoron.uhabits.unit.commands;
|
||||
|
||||
import android.support.test.runner.*;
|
||||
import android.test.suitebuilder.annotation.*;
|
||||
package org.isoron.uhabits.commands;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
import org.isoron.uhabits.commands.*;
|
||||
import org.isoron.uhabits.models.*;
|
||||
import org.junit.*;
|
||||
import org.junit.rules.*;
|
||||
import org.junit.runner.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@SmallTest
|
||||
public class DeleteHabitsCommandTest extends BaseAndroidTest
|
||||
public class DeleteHabitsCommandTest extends BaseUnitTest
|
||||
{
|
||||
private DeleteHabitsCommand command;
|
||||
|
||||
@@ -51,7 +44,7 @@ public class DeleteHabitsCommandTest extends BaseAndroidTest
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
fixtures.purgeHabits(habitList);
|
||||
fixtures.purgeHabits();
|
||||
habits = new LinkedList<>();
|
||||
|
||||
// Habits that should be deleted
|
||||
@@ -17,25 +17,16 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.isoron.uhabits.unit.commands;
|
||||
package org.isoron.uhabits.commands;
|
||||
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
import org.isoron.uhabits.*;
|
||||
import org.isoron.uhabits.models.*;
|
||||
import org.junit.*;
|
||||
|
||||
import org.isoron.uhabits.BaseAndroidTest;
|
||||
import org.isoron.uhabits.commands.EditHabitCommand;
|
||||
import org.isoron.uhabits.models.Habit;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import static org.hamcrest.MatcherAssert.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@SmallTest
|
||||
public class EditHabitCommandTest extends BaseAndroidTest
|
||||
public class EditHabitCommandTest extends BaseUnitTest
|
||||
{
|
||||
|
||||
private EditHabitCommand command;
|
||||
@@ -17,31 +17,23 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.isoron.uhabits.unit.commands;
|
||||
package org.isoron.uhabits.commands;
|
||||
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
import org.isoron.uhabits.*;
|
||||
import org.isoron.uhabits.models.*;
|
||||
import org.isoron.uhabits.utils.*;
|
||||
import org.junit.*;
|
||||
|
||||
import org.isoron.uhabits.BaseAndroidTest;
|
||||
import org.isoron.uhabits.commands.ToggleRepetitionCommand;
|
||||
import org.isoron.uhabits.models.Habit;
|
||||
import org.isoron.uhabits.utils.DateUtils;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import static junit.framework.Assert.*;
|
||||
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@SmallTest
|
||||
public class ToggleRepetitionCommandTest extends BaseAndroidTest
|
||||
public class ToggleRepetitionCommandTest extends BaseUnitTest
|
||||
{
|
||||
|
||||
private ToggleRepetitionCommand command;
|
||||
private Habit habit;
|
||||
private long today;
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp()
|
||||
{
|
||||
@@ -17,26 +17,17 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.isoron.uhabits.unit.commands;
|
||||
package org.isoron.uhabits.commands;
|
||||
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
import org.isoron.uhabits.*;
|
||||
import org.isoron.uhabits.models.*;
|
||||
import org.junit.*;
|
||||
|
||||
import org.isoron.uhabits.BaseAndroidTest;
|
||||
import org.isoron.uhabits.commands.UnarchiveHabitsCommand;
|
||||
import org.isoron.uhabits.models.Habit;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import java.util.*;
|
||||
|
||||
import java.util.Collections;
|
||||
import static junit.framework.Assert.*;
|
||||
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@SmallTest
|
||||
public class UnarchiveHabitsCommandTest extends BaseAndroidTest
|
||||
public class UnarchiveHabitsCommandTest extends BaseUnitTest
|
||||
{
|
||||
private UnarchiveHabitsCommand command;
|
||||
private Habit habit;
|
||||
Reference in New Issue
Block a user