android gradle 单元测试,安卓:与gradle这个单元测试(Android: unit testing with gradle

我有我可以运行在Android Studio中就好了下面的单元测试,但我试图把它建立持续集成,所以我需要gradle这个才能够运行。

package com.smartsocialmedia.tests;

import android.test.InstrumentationTestCase;

import com.smartsocialmedia.utility.DbConnector;

import org.apache.http.message.BasicNameValuePair;

import org.json.JSONObject;

import java.util.ArrayList;

public class MainTest extends InstrumentationTestCase

{

/*

* Testing DbConnector

* public JSONObject getJsonObject(ArrayList params, boolean isGet)

* pass false as second parameter if GET is to be used rather than POST

* in this case we are calling auth/login in the API

*/

public void testGETJSONOBJECT() throws Exception {

//Create an ArrayList of BasicNameValuePair to represent the login information.

ArrayList postParams = new ArrayList();

postParams.add(new BasicNameValuePair("eMail", "myemail"));

postParams.add(new BasicNameValuePair("Password", "mypassword"));

DbConnector db = new DbConnector("auth/login");

JSONObject jsonObject = db.getJsonObject(postParams, false);

//check that the server response is a jsonObject

assertNotNull(jsonObject);

//check that we have expected parameters in the response

int valid = jsonObject.getInt("valid");

assertEquals(valid, 1);

}

}

Basically./gradlew不符合这个测试做什么...我需要知道我需要在gradle这个改变,以便为它工作。

buildscript {

repositories {

mavenCentral()

}

dependencies {

classpath 'com.android.tools.build:gradle:0.9.+'

}

}

apply plugin: 'android'

repositories {

mavenCentral()

}

android {

compileSdkVersion 19

buildToolsVersion '19.0.0'

lintOptions {

checkReleaseBuilds false

// Or, if you prefer, you can continue to check for errors in release builds,

// but continue the build even when errors are found:

abortOnError false

}

defaultConfig {

minSdkVersion 14

targetSdkVersion 19

versionCode 7

versionName "1.0.5"

testPackageName "com.smartsocialmedia.tests"

}

buildTypes {

release {

runProguard false

proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'

}

}

}

dependencies {

compile 'com.android.support:support-v4:18.0.0'

compile 'org.apache.httpcomponents:httpmime:4.1.2@jar'

compile 'com.github.chrisbanes.actionbarpulltorefresh:library:+'

compile files('libs/universal-image-loader-1.9.1-with-sources.jar')

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值