andorid测试笔记


@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也会被执行,

你可能感兴趣的:(andorid测试笔记)