public class ProgressService { public Integer getCurrentProgerss(double current, double max) { Integer i=(int)((current / max) * 100) ; return i; } }
具体步骤如下:
import android.test.InstrumentationTestCase; public class TestClass extends InstrumentationTestCase { public void test() throws Exception{ ProgressService progressService=new ProgressService(); Integer pro=progressService.getCurrentProgerss(20, 70); Log.i(TAG, pro.toString()); } }
选中刚刚新建的测试类TestClass,右键->run->TestClass,如图:
Android开发基础之Android Studio单元测试
原文地址:http://blog.csdn.net/xufeng0991/article/details/44098091