How to prevent some of the unittest files from running - android

I have few unit tests setup using juit in unittest1.java unittest2.java unittest3.java in android.
I want unittest1 and unittest2 not run when I am writing unittest3.java. Is there a way to do that. Googgling did not yield much.
Thanks.

Just go inside your unittest3.java and click Ctrl+F11 for Run or F11 for Debug. This will run only tests inside current class.
Also, you can setup Run/Debug configurations manually. Assuming I have MacTest.java file with MacTest class inside:

Related

Appium Native View, how to click the button to go back to the previous screen

I am pretty new to Appium, using UIAutomator2. Following instructions on the links:
[https://discuss.appium.io/t/click-back-button-on-android-device-in-java/6817/3][1]
[https://discuss.appium.io/t/click-back-button-twice-in-android-7-using-appium-uiautomator2/20368][2]
[https://stackoverflow.com/questions/30801879/how-to-automate-the-android-phone-back-button-using-appium][3]
I have tried all the options offered in these articles:
driver.pressKeyCode(4);
helper.driver.pressKeyCode(187);
driver.back();
driver.navigate().back();
If I add the imports
import io.appium.java_client.android.nativekey.AndroidKey;
import io.appium.java_client.android.nativekey.KeyEvent;
and I try
driver.pressKeyCode(AndroidKeyCode.BACK);
Eclipse tells me that the method is undefined...
But none of them have worked. Is there anything I need to import or any additional classes I need to create? My driver only has methods for testing, such as close(), equals(), execute(), findElement()... but nothing like back(), or pressKeyCode() or navigate()(this one, probably, because it is not webView)... So, when I try to just type any of those methods, Eclipse either suggests to add a cast, or to create a class...
Please, Can anyone give me some more details on how to do it?
The driver should be an Appium driver. And try to run on real device than emulators.
driver = new AppiumDriver<>(url, desiredCapabilities);

How click on standart android button in autotest using Ruby, Appium?

Help Please.
I use:win 7, ruby 2.0.0, appium 1.3.7.0
I test android app.
In test suite, in my steps I define:
Appium.back
I try tap on hardware(native) button e.g. back, home.
but if I run test, appears next error :
NoMethodError: undefined method 'back' for Appium:Module
ansver to my question
in env.rb write
$capy_driver = Capybara.current_session.driver
and use in steps
$capy_driver.go_back
or
$capy_driver.appium_driver.press_keycode 4

Debugging pop up window "Missing Manifest?"

Im getting this error message. I created a new project and hit debug to test it. I added nothing and i get this pop up message. what could be my issue? I can create a new blank project wtih out the Controllers and Models projects in them it debugs just fine. But i need to use this solution provided to me.
New to mono droid any help will be apreciated.
You issue could be that none of the projects have been set to be deployed to a device.
Right click your Solution > Properties > Configuration Properties > Tick The Deploy checkbox for your Application Project if not already.
Also make sure to mark one of your activities with MainLauncher = true, otherwise Android does not know which Activity to start first. This is done in the [Activity()] attribute like so:
[Activity(Label = "Epic Activity", MainLauncher = true, Icon = "#drawable/icon")]
public class Activity1 : Activity {}
what could be my issue?
You are using Visual Studio... Android plays much nicer with Eclipse.
Kidding aside, every Android application requires an AndroidManifest.xml file. It looks like you are using MonoDroid, and there are docs about creating the manifest file.
Also, make sure you have built the project.
AndroidManifest.xml is generated as part of the build process, and the XML found within Properties\AndroidManifest.xml is merged with XML generated based on custom attributes.

Keyboard shortcut for Run As -> Android JUnit Test in Eclipse

Anybody figured out the keyboard equivalent of this menu?
I have been using this menu on test cases infused with Robotium with class signatures like:
public class AccountTest extends ActivityInstrumentationTestCase2<MainActivity> { ... }
Somehow, Alt-Shift-X, T just doesn't quite do the same thing even if you select the Android JUnit Runner in the dialog that pops up...
The similar Run As -> Android Application has a tricky shortcut of Alt-Shift-A, R when launching every other conceivable type of runnable begins with Alt-Shift-X, so there is hope.
Window -> Preferences -> Run/Debug -> Launching -> Always launch the previously launched application.
Run the test case, either the whole thing, or a particular test method, once. It then becomes available to run again in the history. Press the Run or Debug button's drop down menu. Select the configuration you want to run.
From then on, F11 or Ctrl+F11 (debug or run) rinses and repeats the exact same thing again.
type type type, F11, observe results, type type type. No mouse. Very productive.
On my macbook I'm using Shift-Command-Fn-F11.
I am using a similar shortcut but for TestNG, in my case, the shortcut is SHIFT + ALT + X, G
So when I press SHIFT + ALT + X, I get a small window at bottom right side as:
Once I see this window on the bottom right, as I hit the key G, it launches TestNG Suite as expected.

Android Debugging, how?

Ok so I've finally cobbled enough working parts into my app that its just plain old refusing to do anything now. I understand how to use logcat, but that is about it.
The main problem at the moment is that I get the error
Activity Idle Timeout for HistoryRecord then my package
I need to learn how to do better debugging. Plus if anyone can suggest things I should do for this error please let me know.
I think its something to do with the interactions with the database.
Cheers
EDIT:
What IDE are you using, if any?
Eclipse with Android tool has
moderately good debugging facilities;
set a breakpoint and debug away.
I am using Eclipse
And I know of breakpoints, but not their real use. Where would I set them for this error?
I am used to PHP where errors tell you a specific line to look at is there a way to do this in Eclipse?
In Eclipse if you right click in the margin next to your code - easy place to start is probably in your onCreate method - you can choose to Toggle Breakpoint. This will set a breakpoint at that location.
Now, in Eclipse choose Run->Debug As->Android Application.
This will run your app in the emulator and your app with stop running at your breakpoint. At this point you can step thru your code line by line using F6 I believe.
Once you've hit the breakpoint and your code is paused, use a guide like this http://www.ibm.com/developerworks/library/os-ecbug/ which will highlight all the different things you can do at that point.
Max... If you can wrap the offending line of code in try catch you can log the exception or set a breakpoint at the exception. So for the code below that will throw an exception:
String test= null;
try {
test.length();
}
catch (Exception e) {
Log.d(TAG,"test",e);
}
LogCat will display test,java.lang.NullPointerException blah, blah, blah
OR you can set a breakpoint at the Log.d line and if hit in DEBUG mode the app will pause and the variable window in the DEBUG view will show:
this:MyApp e:NullPointerException
BUT it does not sound like your app is throwing an exception, rather it is timing out on a database call. I would stub out the call to the database and see if the timeout goes away. Then slowly add back code until it times out.
JAL

Categories

Resources