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