简书链接:andorid测试笔记
文章字数:27,阅读全文大约需要1分钟

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52

@RunWith(AndroidJUnit4.class)
public class JMETest {

public static String readFromFileByText(File file) throws IOException {
String line;
StringBuffer sb = new StringBuffer();
FileReader fr = new FileReader(file);
BufferedReader br = new BufferedReader(fr);
while ((line = br.readLine()) != null) {
sb.append(line);
}
br.close();
fr.close();
return sb.toString();
}


@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();

assertEquals("cn.ijiami.mydemo", appContext.getPackageName());
}

@Before
public void setUp() throws Exception {
System.out.println("setUp");
Context context = getContext();
// JMEncryptBox.context=context;//load so
// System.out.println(JMEncryptBox.context);

String key = "xxxx";
StatusInfo statusInfo = JMEncryptBox.setLicenseKey(key);
System.out.println(statusInfo.getStatusDescribe());
System.out.println(statusInfo);

System.out.println("setUp end");
}

@Test
public void testSave() throws Exception {

System.out.println("testSave");

String line = JMEncryptBox.encryptToBase64("123456", AlgorithmType.AES);
System.out.println(line);

System.out.println("testSave end");
}

测试testSave,那么其中 setUp也会被执行,