Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unit tests #35

Merged
merged 1 commit into from
Jan 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation ('androidx.test.ext:junit:1.1.1') {
androidTestImplementation('androidx.test.ext:junit:1.1.1') {
exclude group: 'com.android.support', module: 'support-annotations'
}
androidTestImplementation('androidx.test:runner:1.5.2')
androidTestImplementation('androidx.test:core:1.5.0')
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'com.prolificinteractive:material-calendarview:1.4.3'
implementation ("com.github.bumptech.glide:glide:4.6.1") {
implementation("com.github.bumptech.glide:glide:4.6.1") {
exclude group: "com.android.support"
}
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,21 @@ License, or (at your option) any later version.
*/
package org.secuso.privacyfriendlypaindiary;

import android.app.Application;
import android.test.ApplicationTestCase;
import static org.junit.Assert.assertEquals;

import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;

import org.junit.Test;
import org.junit.runner.RunWith;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
@RunWith(AndroidJUnit4.class)
public class ApplicationTest {
@Test
public void instrumentationTest() throws Exception {
assertEquals("org.secuso.privacyfriendlypaindiary", InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@ License, or (at your option) any later version.
*/
package org.secuso.privacyfriendlypaindiary;

import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import static junit.framework.TestCase.assertNotNull;
import static junit.framework.TestCase.fail;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.secuso.privacyfriendlypaindiary.database.DBService;
import org.secuso.privacyfriendlypaindiary.database.PainDiaryDatabaseService;
import org.secuso.privacyfriendlypaindiary.database.entities.enums.BodyRegion;
import org.secuso.privacyfriendlypaindiary.database.entities.enums.Condition;
import org.secuso.privacyfriendlypaindiary.database.entities.enums.Gender;
Expand All @@ -47,15 +52,9 @@ License, or (at your option) any later version.
import java.util.List;
import java.util.Set;

import static junit.framework.TestCase.assertNotNull;
import static junit.framework.TestCase.fail;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;

/**
* This class tests the basic database functionality, i.e. the methods of the class
* {@link DBService}.
* {@link PainDiaryDatabaseService}.
*
* @author Susanne Felsen
* @version 20180110
Expand All @@ -65,17 +64,17 @@ License, or (at your option) any later version.
@RunWith(AndroidJUnit4.class)
public class DBServiceTest {

DBService service;
PainDiaryDatabaseService service;

@Before
public void setUp() {
service = DBService.getInstance(InstrumentationRegistry.getTargetContext());
service.reinitializeDatabase();
service = PainDiaryDatabaseService.getInstance(InstrumentationRegistry.getInstrumentation().getTargetContext());
service.reinitializeDatabase(InstrumentationRegistry.getInstrumentation().getTargetContext());
}

@After
public void tearDown() throws Exception {
service.close();
//service.close();
}

@Test
Expand Down Expand Up @@ -169,7 +168,7 @@ public void testDiaryEntryAndAssociatedObjects() {
assertEquals("Times of Pain were incorrect.", timesOfPain, painDescription.getTimesOfPain());

Set<DrugIntakeInterface> intakes = entry.getDrugIntakes();
assertEquals("Number of Drug Intakes was incorrect.", 1, intakes.size());
assertEquals("Number of Drug Intakes was incorrect.", 1, intakes.size());
drugIntake = intakes.iterator().next();
assertEquals("Quantity Morning was incorrect.", quantityMorning, drugIntake.getQuantityMorning());
assertEquals("Quantity Noon was incorrect.", quantityNoon, drugIntake.getQuantityNoon());
Expand Down