I have an application, the Authorization class in it, there is a method in the class:

private void login() { if (!RCP.NOT_LOGIN) return; String info = null; int worning = 0; String login = textLogin.getText().toString().trim(); String passHash = hash( hash(textPass.getText().toString(), "SHA-1"), "MD5"); info = DbWorker.setUser(login); // проверка успешности создания пользователя if (info == null) info = DbWorker.checkPass(passHash); else worning = R.string.aut_wrong_user_name; // проверка корректности ввода пароля if (info == null) info = DbWorker.checkActive(); else if (worning == 0) worning = R.string.aut_wrong_user_pass; // проверка легитимности пользователя if (info == null) info = DbWorker.logIn(); else if (worning == 0) worning = R.string.aut_wrong_user_activate; // проверка валидности пользователя if (info == null) info = DbWorker.setFIO(); else if (worning == 0) worning = R.string.aut_wrong_permission; // проверка наличия прав доступа if (info == null) if (port.isChecked()) { inten2(); } else { inten();} else if (worning == 0) worning = R.string.autho_error_reg_not_found; if (worning != 0) errorMes(worning).show(); // запись в журнале, при неудачной регистрации if (RCP.NOT_LOGIN) DbLog.writeEvent(DbLog.EV_USER_LOGIN_FAILURE, 3, info, 0, 0, 0, 0, 0); } 

I want to make a unit tests, so that every time after the next "rework" in hand, not to test this part. Unit tests, never wrote, but apparently that time has come.

Maybe one of you has already been in a similar situation and will advise where to start?

Ps read the drone documentation, and now read the "Android Application Testing Guide" from Diego Torres Milano. But I would like to find an example "on the fingers" in IDE ECLIPSE. Maybe someone does not mind the time, post a simple example, according to the above code (on the legitimacy of the entered data in the login and password fields))))

    1 answer 1

    After a long search I came to the conclusion about the inevitability of using AndroidStudio as an IDE. I never found any intelligible, easy-to-learn unit testing in the realities of Eclipce (under Androyd).

    Google itself considers the main tool for testing Ecspresso, the documentation is quite simple and describes everything in detail. Ecspresso itself, can be used after importing the project into AndroidStudio, in principle, there were no problems.

    But there is a nuance, if you upgrade the Android SDK Build-Tools to versions above 24.0.1, ADB may not work under Windows XP. I had to install an older version and ignore updates (.

    The process of creating and running tests is described in the official documentation in great detail, so go for it. Here is a short article ( in Russian ) for understanding the basic principles.

    • one
      Androyd Studio also works under Linux (for example, Ubuntu). Would you like to try? It is not difficult. Just to not face restrictions due to the OS. - DimXenon 2:21 pm
    • @DimXenon. Yes, you are right, but in the context of my project there is a deskopnaya part under Windows, but a users - government officials in the vast majority of them use Windows XP. This is what dictates my binding to the OS. - Yauheni
    • OK. I am familiar with state services. Understand. I have no more questions. - DimXenon