lundi 8 août 2016

How do I unit-test this class in Android?

How can I test this class in Android to verify that it does indeed open up an email sender app picker, and when an app is selected, the fields are pre-filled and the file is attached?

Should it be a unit test or an integration test or an automated test through the UI. What kind of set up do I need and how can I test only this class in isolation:

public class EmailSender {

    public static void sendEmailWithAttachment(Context context,
                                               String[] recipient,
                                               String subject,
                                               String attachmentFilePath) {
        Intent emailIntent = new Intent(Intent.ACTION_SEND);
        emailIntent .setType("http://ift.tt/1hDVSkY");
        emailIntent .putExtra(Intent.EXTRA_EMAIL, recipient);
        emailIntent .putExtra(Intent.EXTRA_STREAM, attachmentFilePath);
        emailIntent .putExtra(Intent.EXTRA_SUBJECT, subject);
        context.startActivity(Intent.createChooser(emailIntent , "Send email..."));
    }

}

Aucun commentaire:

Enregistrer un commentaire