android gradle 单元测试,Android:单元测试与gradle

我有以下单元测试,我可以在android studio中运行得很好,但我试图让它设置为持续集成,所以我需要gradle才能运行它。Android:单元测试与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);

}

}

基本上./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:[email protected]'

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

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

}

2014-03-24

ed209

+0

你试图gradlew connectedAndroidTest? –

+0

你正在运行什么gradle任务?如果一切正常,connectedCheck将在/ androidTest /中运行测试。 –

+0

@ ed209你解决了吗? –

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值