What steps will reproduce the problem?
1.Installing the APK on the CircleCI emulator
2.Installing the APKTEST on the CircleCI emulator
3.Running the test with
"adb shell am instrument -w
net.testshopontop/android.test.InstrumentationTestRunner"
also I tried with "fb-adb shell am instrument -w
net.testshopontop/android.test.InstrumentationTestRunner"
and if the test failed its still return exit code 0
please see the below link :
https://s3-eu-west-1.amazonaws.com/uploads-eu.hipchat.com/136279/999605/dQ4B6r6V
sLJczLC/upload.png
What is the expected output? What do you see instead?
I would like the build will failed or to get exit code 1 instead of exit code 0
if the robotium test fail.
What version of the product are you using? On what operating system?
robotium solo 5.4.1.jar
Please provide any additional information below.
the command output
"net.testshopontop.TestApk:
Failure in testRun:
junit.framework.AssertionFailedError: View with id: 'splash_cuube_login_button'
is not found!
at com.robotium.solo.Solo.getView(Solo.java:2978)
at com.robotium.solo.Solo.getView(Solo.java:2954)
at net.testshopontop.TestApk.testRun(TestApk.java:58)
at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1853)
Test results for InstrumentationTestRunner=.F
Time: 29.296
FAILURES!!!
Tests run: 1, Failures: 1, Errors: 0
0"
my test
"
package net.testshopontop;
import com.robotium.solo.*;
import android.annotation.TargetApi;
import android.os.Build;
import android.test.ActivityInstrumentationTestCase2;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.ProtocolException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.nio.charset.Charset;
import java.util.List;
import javax.net.ssl.HttpsURLConnection;
@SuppressWarnings("rawtypes")
public class TestApk extends ActivityInstrumentationTestCase2 {
// /private static final String TAG = "RoboDebug";
private Solo solo;
private static final String LAUNCHER_ACTIVITY_FULL_CLASSNAME = "net.shopontop.ShopOnTopActivity";
private static Class<?> launcherActivityClass;
static{
try {
launcherActivityClass = Class.forName(LAUNCHER_ACTIVITY_FULL_CLASSNAME);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
@SuppressWarnings("unchecked")
public TestApk() throws ClassNotFoundException {
super(launcherActivityClass);
}
public void setUp() throws Exception {
super.setUp();
solo = new Solo(getInstrumentation());
getActivity();
}
@Override
public void tearDown() throws Exception {
solo.finishOpenedActivities();
super.tearDown();
}
//@TargetApi(Build.VERSION_CODES.KITKAT)
public void testRun() throws IOException {
try {
////Sending GET to clean User Cart etc.
String url =
"http://apiv1.mobileappapi.com/ci/invalidate_user?deviceId=7e093e6454bb4aa9a1e2cec282f90eca";
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
//Optional default is GET
con.setRequestMethod("GET");
//Add request header
con.setRequestProperty("User-Agent", "Mozilla/5.0");
//Should be 200
int responseCode = con.getResponseCode();
//////////
//User Details for logins
String userName = "johnsmith@dealply.com";
String userPswd = "123456";
//Wait for activity: 'net.shopontop.ShopOnTopActivity'
solo.waitForActivity("ShopOnTopActivity", 2000);
//Wait for activity: 'coda.RootActivity'
assertTrue("RootActivity is not found!", solo.waitForActivity("RootActivity"));
//PRESS LOGIN STARTING BUTTON
solo.clickOnView(solo.getView("splash_cube_login_button"));
solo.sleep(2000);
//ENTER USERNAME AND PASSWORD
solo.sleep(2000);
solo.clickOnEditText(0);
solo.enterText(0, userName);
boolean assertUsername = solo.searchEditText(userName);
assertEquals("userName entered is not matching", true, assertUsername);
solo.enterText(1, userPswd);
boolean assertPswd = solo.searchEditText(userPswd);
assertEquals("user passWord entered is not matching", true, assertPswd);
solo.clickOnView(solo.getView("login_button")); //Click on login
solo.sleep(2000);
//buy aproduct
//assertTrue("not buying", solo.waitForText(solo.getString("buy")));
solo.sleep(16000);
/*int z = 0;
while (solo.getView("button_buy_product",z).getVisibility() != View.VISIBLE) {
z+=1;
}*/
solo.clickOnView(solo.getView("button_buy_product"));
if (solo.searchText(solo.getString("add_to_cart"))) {
solo.clickOnView(solo.getView("product_options_button"));
}
//checking menu shopping cart counter
String cart_string = solo.getString("action_cart");
solo.clickOnMenuItem(cart_string);
solo.sleep(2000);
int j = 0;
while (solo.getView("drawer_notification_count", j).getVisibility() != View.VISIBLE) {
j += 1;
}
TextView notify = (TextView) solo.getView("drawer_notification_count", j);
String Val = notify.getText().toString();
boolean res = (Val.equals("1"));
solo.sleep(2000);
assertTrue("Wrong Quantity Check", res);
solo.clickOnMenuItem(cart_string);
solo.sleep(2000);
//continue to checkout
solo.clickOnView(solo.getView("shopping_cart_pay_button"));
solo.sleep(2000);
//assert checkout dialogue
assertTrue("Failed Card Number Check",
solo.searchText(solo.getString("card_number")));
assertTrue("Failed Credit Card Check",
solo.searchText(solo.getString("credit_card")));
assertTrue("Failed First Name, Last Name Check",
solo.searchText(solo.getString("first_name_last_name")));
assertTrue("Failed Credit Card Holder Check",
solo.searchText(solo.getString("credit_card_holder_name")));
assertTrue("Failed CVV2 Check",
solo.searchText(solo.getString("cvv")));
assertTrue("Failed Security Code Check",
solo.searchText(solo.getString("credit_card_security_code")));
assertTrue("Failed Expiry Date Check",
solo.searchText(solo.getString("expiry_date")));
assertTrue("Failed MM/YY Check",
solo.searchText(solo.getString("expiry_date_hint")));
assertTrue("Failed Save Paymenty Info Check",
solo.searchText(solo.getString("save_payment_info")));
}catch(RuntimeException e){System.exit(200);}
}
}
"
Awaiting for early response !
Thanks in advance !
Original issue reported on code.google.com by gabayli...@gmail.com on 21 Jun 2015 at 1:06
Original issue reported on code.google.com by
gabayli...@gmail.com
on 21 Jun 2015 at 1:06