How to do automatic, on device tests for react native application? - testing

I want to create automatic tests for an application written in react native. I want to test only logic (not the UI).
Jest seems to be great solution for unit or even integration tests which will be run on a computer. But I would like to test the application on a real device. I have a component without UI that does some logic, wireless communication with other devices etc. I need to test that communication especially, which cannot be done without a device.
Are there any frameworks or standard solutions to do such thing?

Ok, I did my research about testing react native applications.
At the moment ReactNative doesn't provide a platform independent test framework that could run integration (not UI) tests on real device. In fact there is a RCTTestRunner but it's functionality is limited and it works only for iOS devices.
Functional tests
There are multiple functional test frameworks. These tests mainly depend on UI components and are used for black-box testing of user interactions. There are two mature cross platform frameworks that could be used for that: Calabash and Appium. Appium seems to be better solution as it's a single tool for both platforms (Calabash is actually set of two projects for iOS and Android). Also Appium supports multiple languages (JavaScript, Python, Java, ...) when Calabash supports only Ruby.
There is also a Cavy project that looks promising but uses React ref generating functions in a hacky way and needs multiple modifications in the application code.
But all of that is intended to do only UI testing.
Workaroud solution
The solution which I used to test logic of the application (without being influenced by UI changes) is following. I created special version of the application (by creating new target) which have replaced the main UI component with test one. That test component runs on the top of the application. It is just triggering tests and displaying the logs. These logs are then read and parsed by functional test framework to produce the report.

Related

Detox and React <-> WebView interaction

I wonder if there is any plan to make Detox interact with React Webview. I have seen older articles like the one below in Mid 2018 where it was said to be out of scope. But since we're in 2019 close to Q2, just wanted to check if there are any new plans to implement this from Detox? That would be very beneficial for us given we are planning to use Detox for our cross platform UI automation for our React Native apps. There maybe a few hacks that could work like suggested below but there will be security concerns within the org in implementing such hacks.
How can I controle React-Native webview in Detox?
Detox supports both iOS and Android apps, so I'll separate the answers:
On iOS, Detox uses EarlGrey to synchronize, match and perform actions. EarlGrey runs in-process, and was design for native UI hierarchy, such that has accessibility details. Moreover, web content on iOS is rendered inside a WKWebView, which runs out-of-process, so technically this is not possible (and there are no plan to support it currently). This might be possible with XCUITest (and EarlGrey2, whenever it will be released).
On Android, Espresso supports running on WebViews, but Detox does not export that functionality.

Mobile Game automation testing using Appium,Opencv and Bitbar Akaze (Image Recognition)

I want to learn how to test mobile games using Appium, so i found it could be done using Image Recognition.
I found this https://bitbar.com/appium-tip-27-using-appium-for-mobile-game-testing/
I'm truly stuck in it
couldn't understand what i should do or add in Eclipse to test mobile games using Appium.
If anyone know how to test mobile game using Appium rather than Image Recognition please tell me.
Please, if any one have any tutorial or a clear steps of mobile game testing automation tell me.
Appium is not a good option (unless you are ok with image recognition approach) to test mobile games. Appium is using native test frameworks like UIAutomator, Espresso (Android) and XCUITest (iOS), that are basically implemented to test apps build with native SDK
Mobile games are mostly build with engines like Unreal, Unity, Corona ,etc. that have no relation to native SDK and thus cannot be tested with native test frameworks without additional tweaks.
Basically following issues to be addressed and add support for:
find elements
check action occurring in game
check UI rendered
properly
There are some projects where engineers are trying to use Appium with some additional ports, e.g. Unity-Appium, but there is definitely nothing like Appium or Selenium that you can take and use like silver bullet.
Check the engine your game is based on and search for possible test frameworks.

Before Start React Native what are the basic language known

I have experience in iOS native develop. I am new to react native. before to start what are language i must be familiar?. like Java Script
I clearly depends on what exactly do you want to do.
Only React Native? Then it is just a mix of JavaScript and Node.JS. You don't specifically use HTML, but CSS helps because it uses the same concept and classes.
Do you want to also have a custom package? You will need some basic knowledge in Android/Java and iOS.
Do you want to add Unit Testing / Automation? Jest, which is basically JavaScript and Appium for example. The latter supports varios languages but you might want to tart with Python because you can run that in Cloud services for automation.
Then, are you going to build the backend too? NodeJS, Java, Net, PHP, Python, etc, etc, etc.

Main differences between Appcelerator Titanium and React native

Both frameworks are (hybrid) mobile app frameworks which try to access the native UI components with the JavaScript API provided by the different platforms like iOS and Android. They don't use any HTML and CSS for the UI design like e.g. Ionic do and they are not wrapper frameworks but actually a kind of cross-compiler frameworks. That's what i found out. BUT I didn't get the actual differences between these two frameworks. Why should i prefer one of these? Are they doing exactly the same job?
best regards, Tom
I know this is quite old, but I'll give my answer for the benefit of anyone else arriving here.
Full disclosure, I worked for Appcelerator from 2012-2019.
In short, they're both quite similar.
You write a specific flavor of JavaScript that includes custom objects
Your JavaScript code gets compressed, minified, etc. so it becomes the input to an interpreter that gets shipped with your app
When your app runs, it launches the interpreter which starts executing your code
At this point, JavaScript is being run in "native land", so the interpreter can act as a bridge between your JavaScript code and the native SDK
The result is a native app with access to features of the underlying platform
A "native app" shouldn't simply be defined as an app that runs natively, because that would make a PhoneGap app a native app.
A "native app" should be defined as an app that runs and behaves natively. That means, an app that abides by the native OS' ui/ux guidelines.
MAIN DIFFERENCES?
I'd have to say that the main difference is its internal design. Appcelerator started in 2007, when "mobile" was very young.
React Native was launched in 2015.
In 2015 mobile was already in full swing, and mobile OS' were pretty mature, so I infer that React Native's design benefits from all lessons learned by Appcelerator (and others).
As for which one is better, I'd say React, because Titanium is now dead.

Automated user interface testing in Titanium

How can I create automated user interface tests for a Titanium app? Does the framework include something for this? Are there any helpful third party tools?
Have you looked at titanium-jasmine?
I have never personally used it but ive heard its pretty useful for this type of thing. I'm not sure about its abilities to test actually visual elements.
EDIT:
For testing the user interface and simulating touch events on the simulator or device, just use UIAutomation with the native workflow! Since every Titanium project compiles to an XCode project (which can and should be at least profiled for memory leaks using the native workflow before release to the app store), you can just follow the steps here to write your own tests in Javascript.
As a first step, run your app in the simulator, then got to PROJECT_HOME/build/ and open up the xcodeproj file. Once inside XCode, hold down the "Run" button, click "Profile", which will open up "Instruments" and add the "Automation" widget like in the link I provided!
This is not titanium specific, it can be used for any iOS app and seems like a great tool for every iOS developer, along with Allocators and Memory Leak widgets inside of instruments.
Possibly a better alternative is using Gorilla Logic's free MonkeyTalk. It is a bit more straightforward if your not very experienced with XCode, and it has the benefit of (theoretically) being able to test iOS and Android.