本文主要介紹在android studio中進(jìn)行單元測(cè)試的方式,你將了解到
1.如何在android studio中引用JUnit4
2.單元測(cè)試Demo
引用模塊
然后在build.gradle中添加
compile 'com.jakewharton.espresso:espresso:1.1-r3'
Demo
新建一個(gè)Calculator 測(cè)試它的方法
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;
}
}