2016-04-29 3 views
5

मैंने वास्तव में एस्प्रेसो के साथ कुछ यूनिट परीक्षण सेट करने का प्रयास किया और कुछ घंटों के शोध के बाद ऐप केवल क्लिक करता है और एडिटटेक्स्ट द्वारा फोकस करता है लेकिन उसके बाद कुछ भी नहीं हैसरल एस्प्रेसो परीक्षण "60sec से अधिक x पुनरावृत्तियों के लिए लूप" त्रुटि

Caused by: android.support.test.espresso.AppNotIdleException: Looped for 1996 iterations over 60 SECONDS. The following Idle Conditions failed . 

मैं सभी एनीमेशन & SwipeRefreshLayout हटा दिया है कारण मैंने देखा वहाँ swiperefresh साथ एक बग है

मैं वास्तव में कुछ कॉलबैक का उपयोग के लिए गतिविधि

कुछ करता है, तो में वर्तमान टुकड़ा की जगह

// App dependencies 
compile 'com.android.support:support-annotations:23.3.0' 
compile 'com.google.guava:guava:18.0' 
// Testing-only dependencies 
// Force usage of support annotations in the test app, since it is internally used by the runner module. 
androidTestCompile 'com.android.support:support-annotations:23.3.0' 
androidTestCompile 'com.android.support.test:runner:0.4.1' 
androidTestCompile 'com.android.support.test:rules:0.4.1' 
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2' 
androidTestCompile 'com.android.support.test.espresso:espresso-intents:2.2.2' 

मैं defaultConfig पर इस जोड़ दिया है:

एक कुछ सुझाव मैं u_u खोज

धन्यवाद के 4 घंटे के बाद बाहर हूँ आप :)


मेरे Gradle निर्भरताएं

:
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 

वहाँ अपने परीक्षण है

@RunWith(AndroidJUnit4.class) 
@LargeTest 
public class HelloWorldEspressoTest { 

    public static final String USERNAME = "do_f"; 

    @Rule 
    public ActivityTestRule<LoginActivity> mActivityRule = new ActivityTestRule(LoginActivity.class); 

    private LoginActivity mActivity = null; 

    @Before 
    public void setActivity() { 
     mActivity = mActivityRule.getActivity(); 
    } 

    @Test 
    public void login_LoginActivity() { 

     onView(withId(R.id.menu_login)).perform(click()); 

     onView(withId(R.id.login_username)) 
       .perform(typeText(USERNAME), closeSoftKeyboard()); 
    } 
} 

मेरी गतिविधि नहीं है:

public class LoginActivity extends AppCompatActivity 
     implements MenuFragment.OnFragmentInteractionListener { 

    private FragmentManager fm; 

    public static void newActivity(Activity activity) 
    { 
     Intent i = new Intent(activity, LoginActivity.class); 
     activity.startActivity(i); 
    } 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_login); 
     SharedPreferences sp = getSharedPreferences(Utils.SP, Context.MODE_PRIVATE); 

     if (!sp.getString(Utils.TOKEN, "null").equals("null")) 
     { 
      MainActivity.newActivity(this); 
      finish(); 
     } 

     fm = getFragmentManager(); 
     fm.beginTransaction() 
       .replace(R.id.container, MenuFragment.newInstance()) 
       .addToBackStack(null) 
       .commit(); 
    } 

    @Override 
    public void onBackPressed() 
    { 
     if (getFragmentManager().getBackStackEntryCount() > 1) 
      getFragmentManager().popBackStack(); 
     else 
      super.onBackPressed(); 
    } 

    @Override 
    public void showLogin() { 
     fm.beginTransaction() 
       .replace(R.id.container, LoginFragment.newInstance()) 
       .addToBackStack(null) 
       .commit(); 
    } 

    @Override 
    public void showRegister() { 
     fm.beginTransaction() 
       .replace(R.id.container, RegisterFragment.newInstance()) 
       .addToBackStack(null) 
       .commit(); 
    } 
} 

और मेरे LoginFragment:

private static final String  TAG = "LoginFragment"; 

@Bind(R.id.loading_spinner) 
ProgressBar loading; 

@Bind(R.id.content) 
LinearLayout content; 

@Bind(R.id.login_username) 
EditText  username; 

@Bind(R.id.login_password) 
EditText  password; 

public LoginFragment() { 

} 

public static LoginFragment newInstance() { 
    return new LoginFragment(); 
} 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
} 

@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, 
         Bundle savedInstanceState) { 
    View v = inflater.inflate(R.layout.login_fragment_login, container, false); 
    ButterKnife.bind(this, v); 
    return v; 
} 

@Override 
public void onActivityCreated(Bundle saveInstanceState) { 
    super.onActivityCreated(saveInstanceState); 
} 

@OnClick(R.id.login_submit) 
public void onSubmit(View v) 
{ 
    if (username.getText().length() == 0 
      || password.getText().length() == 0) 
    { 
     Snackbar.make(getView(), "blabla", Snackbar.LENGTH_SHORT).show(); 
     return ; 
    } 
    //hideContent(); 
    LoginPost p = new LoginPost(username.getText().toString(), password.getText().toString()); 
    Call<LoginResponse> call = RestClient.get().login(p); 
    call.enqueue(new Callback<LoginResponse>() { 
     @Override 
     public void onResponse(Call<LoginResponse> call, Response<LoginResponse> response) { 
      if (response.body() == null) { 
       String msg = getResources().getString(R.string.login_error_bad_credentials); 
       Snackbar.make(getView(), msg, Snackbar.LENGTH_SHORT).show(); 
       //showContent(); 
      } else { 
       SharedPreferences sp = getActivity().getSharedPreferences(Utils.SP, Context.MODE_PRIVATE); 
       sp.edit().putString(Utils.TOKEN, response.body().getToken()).apply(); 
       sp.edit().putString(Utils.USERNAME, username.getText().toString()).apply(); 
       MainActivity.newActivity(getActivity()); 
       getActivity().finish(); 
      } 
     } 

     @Override 
     public void onFailure(Call<LoginResponse> call, Throwable t) { 
      Snackbar.make(getView(), "onFailure", Snackbar.LENGTH_SHORT).show(); 
      //showContent(); 
     } 
    }); 
} 

उत्तर

4

मैं समाधान नहीं मिला, लूप में चलाए पुनरावृत्तियों इस

<ProgressBar 
    android:id="@+id/loading_spinner" 
    android:layout_width="150dp" 
    android:layout_height="150dp" 
    android:layout_centerVertical="true" 
    android:layout_centerHorizontal="true" 
    android:indeterminateTintMode="src_atop" 
    android:indeterminateTint="@color/ganjify" 
    android:alpha="0" 
    android:layout_gravity="center" /> 

की वजह से था, क्योंकि मैं ' जब मैं इसका उपयोग नहीं करता हूं तो दृश्यता को सेट नहीं किया गया है!

loading.setVisibility(View.GONE); 
+0

मैं भी एक ही समस्या है, मैं प्रगति के लोड पर चला गया यह जांच और अभी भी एक ही समस्या है ... –

+0

@DineshVG अरे, आप अपने एनीमेशन के सभी करता है, तो जाँच करनी चाहिए करने के लिए के लिए दृश्यता सेट खत्म हो गया है, अन्यथा एस्प्रेसो परीक्षण –

+0

लूप होगा, मेरे लिए वही दृश्यता के बजाय अल्फा 0 सेट करें -> AppNotIdleException (यह स्पष्ट है जब आप इसे जानते हैं: डी) – crysxd

संबंधित मुद्दे