Click here to Skip to main content
14,930,087 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have created a share button and on clicking that you have share app link option where you can share in various app. So I just wanted to test this sharing app. I am new in the android and till now I did not got any good material related to this topic and if got then not understood that much.

Code for share app
protected void onCreate(Bundle savedInstanceState) {

sharebtn = findViewById(;
sharebtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent shareintent = new Intent(Intent.ACTION_SEND);
String shareBody = "Download this one :";
String sharesubject = "learning the share app";

shareintent.putExtra(Intent.EXTRA_TEXT, shareBody);
startActivity(Intent.createChooser(shareintent,"Share Using"));


What I have tried:

I have done testing of dialer with code like that


intended(allOf( hasAction(Intent.ACTION_DIAL), hasData(INTENT_DATA_PHONE_NUMBER), toPackage(PACKAGE_ANDROID_DIALER)));

I was thinking similar to this only in share app also by replacing Intent.ACTION_DIAL to Intent.ACTION_SEND and INTENT_DATA_PHONE_NUMBER to MESSAGE_TO_SENT but not succeeded and later come to know that share app do not have any package as package is related to app only. So I just wanted to know that how can I write the UI test case for share app.
David Crow 29-Apr-21 22:07pm
" can I write the UI test case for share app."

Your question is unclear. Since you are writing the code and therefore know what it is supposed to do, the test case is simply "Does it do it?"

When you click the sharebtn button, does the above code show up? In other words, do you get a "Share Using" dialog?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900