本文主要介绍在android studio中进行单元测试的方式,你将了解到
1.如何在android studio中引用JUnit4
2.单元测试Demo
引用模块
然后在build.gradle中添加
compile 'com.jakewharton.espresso:espresso:1.1-r3'
Demo
新建一个Calculator 测试它的方法
package com.example.news;
/**
* Created by 小新 on 2016/7/1.
*/
public class Calculator {
public double sum(double a, double b){
return a+b;
}
public double substract(double a, double b){
return a-b;
}
public double divide(double a, double b){
return a/b;
}
public double multiply(double a, double b){
return a*b;
}
public double addMore(double a,double b,double c){
return a+b+c;
}
}