Android单元测试问题

时间:2017-08-10 08:25:11

标签: android unit-testing android-testing

package com.rajitha.medi.activities;
import android.support.test.rule.ActivityTestRule;
import android.view.View;
import com.allion.medimap.R;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

import static junit.framework.Assert.assertNotNull;

/**
 * Created by rajitha on 8/10/17.
 */

public class ActivationActivityTest {

    @Rule
    public ActivityTestRule<ActivationActivity> activityActivityTestRule= new ActivityTestRule<ActivationActivity>(ActivationActivity.class);
    public ActivationActivity activationActivity;


    @Before
    public void setUp() throws Exception {
        activationActivity=activityActivityTestRule.getActivity();
    }

    @Test
    public void testrun()
    {
        View view=activationActivity.findViewById(R.id.activationCode);
        assertNotNull(view);
    }

    @After
    public void tearDown() throws Exception {
        activationActivity = null;
    }

}
            View view=activationActivity.findViewById(R.id.activationCode);
            assertNotNull(view);
        }

        @After
        public void tearDown() throws Exception {
            activationActivity = null;
        }

    }
  

这里我为ActivationActivity类添加了单元测试类。但是我遇到了一个名为错误的问题:无法找到符号导入com.rajitha.medi.R;    我的项目包名称是    com.rajitha.medi 我该如何解决这个问题?

     

Logcat-这里我附加了logcat部分,它显示了另一个错误。这两个问题都有一个原因。

error: cannot find symbol
    public ActivationActivity activationActivity;
           ^
  symbol:   class ActivationActivity
  location: class ActivationActivityTest

0 个答案:

没有答案