Skip to content

Commit 42b5339

Browse files
committed
Added new test cases for CarModel and MainActivity
1 parent 9f9ebeb commit 42b5339

2 files changed

Lines changed: 83 additions & 0 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package com.demoapp;
2+
3+
import android.database.SQLException;
4+
import android.support.test.rule.ActivityTestRule;
5+
import android.view.View;
6+
import android.widget.TextView;
7+
8+
import com.demoapp.Models.UserModel;
9+
import com.sqlitemanager.SQLiteManager;
10+
11+
import junit.extensions.ActiveTestSuite;
12+
13+
import org.junit.After;
14+
import org.junit.Before;
15+
import org.junit.Rule;
16+
import org.junit.Test;
17+
18+
import static org.junit.Assert.*;
19+
20+
/**
21+
* Created by aslan on 8/13/2017.
22+
*/
23+
public class MainActivityTest {
24+
25+
@Rule
26+
public ActivityTestRule<MainActivity> mainActivityActivityTestRule
27+
= new ActivityTestRule<MainActivity>(MainActivity.class);
28+
29+
30+
private MainActivity mainActivity;
31+
32+
@Before
33+
public void setUp() throws Exception {
34+
mainActivity = mainActivityActivityTestRule.getActivity();
35+
UserModel userModel = new UserModel();
36+
userModel.profilePicture = "some image uri";
37+
userModel.fullname = "First Last name";
38+
userModel.age = 12;
39+
40+
long feedback = userModel.insert();
41+
assertTrue(feedback > 0);
42+
UserModel newUserModel = new UserModel();
43+
newUserModel.fill(2);
44+
assertTrue(newUserModel.id == 2);
45+
assertNotNull(newUserModel.fullname);
46+
assertNotNull(newUserModel.profilePicture);
47+
assertNotEquals((long) newUserModel.age, 0);
48+
49+
UserModel userModel1 = SQLiteManager.find(UserModel.class, 3);
50+
assertNotNull(userModel);
51+
userModel1.fullname = "sdAmiraslan Bakhshili";
52+
assertTrue(userModel1.update() > 0);
53+
}
54+
55+
@Test
56+
public void testLaunch() {
57+
TextView view = (TextView) mainActivity.findViewById(R.id.myTextView);
58+
assertNotNull(view);
59+
assertEquals(view.getText(), mainActivity.getResources().getString(R.string.my_name));
60+
}
61+
62+
@After
63+
public void tearDown() throws Exception {
64+
65+
}
66+
67+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.demoapp.Models;
2+
3+
import org.junit.Before;
4+
5+
import static org.junit.Assert.*;
6+
7+
/**
8+
* Created by aslan on 8/13/2017.
9+
*/
10+
public class CarModelTest {
11+
@Before
12+
public void setUp() throws Exception {
13+
14+
}
15+
16+
}

0 commit comments

Comments
 (0)