mercredi 1 novembre 2017

What is the best way do integration test for Android google map

My application consist mainly of a single Google Map where I display several marker depending on some user action.

for example:

  • User press button
  • The app contact an external service
  • The get the results and display Markers on the Google Map

I would to know what is the best way to test this on Android? I would 'not' like to mock the external service

I have seen Espresso but apparently based on other SO question cannot access Marker? Has this Changed in newer version?

Appium chrome not reachable Windows 10

I can't run a test thru Appium on a real android device. It's a hybrid app. Keeps getting error

 An unknown server-side error occurred while processing the command. Original error: chrome not reachable

The tests were running fine a couple days ago, and then just stopped working and started showing that error.

Appium Version is at 1.7.1.

Chromedriver at 2.30

I tried to re-install Appium quite a few times and it did not solve the problem. I also tried to add the setProperty() with chromedriver path but did not work as well.

Here is my Appium log. I saw it can see where chromedriver.exe is, but it doesnt matter because test keeps failing when trying to open the WebView Context.

[debug] [AndroidDriver] Found webviews:     ["WEBVIEW_com.mydomain.app"]
[debug] [AndroidDriver] Available contexts:     ["NATIVE_APP","WEBVIEW_com.mydomain.app"]
[debug] [AndroidDriver] Connecting to chrome-backed webview context 'WEBVIEW_com.mydomain.app'
[debug] [AndroidDriver] A port was not given, using random port: 8001
[debug] [Chromedriver] Changed state to 'starting'
[Chromedriver] Set chromedriver binary as:     C:\Users\larissa\AppData\Roaming\npm\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win\chromedriver.exe
[debug] [Chromedriver] Killing any old chromedrivers, running: FOR /F "usebackq tokens=5" %a in (`netstat -nao ^| findstr /R /C:"8001 "`) do (FOR /F "usebackq" %b in (`TASKLIST /FI "PID eq %a" ^| findstr /I chromedriver.exe`) do (IF NOT %b=="" TASKKILL /F /PID %a))
[Chromedriver] No old chromedrivers seemed to exist
[debug] [Chromedriver] Cleaning any old adb forwarded port socket connections
[debug] [ADB] List forwarding ports
[debug] [ADB] Running 'C:\Users\larissa\AppData\Local\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","0024804552","forward","--list"]
[debug] [ADB] Removing forwarded port socket connection: 12323
[debug] [ADB] Running 'C:\Users\larissa\AppData\Local\Android\sdk\platform-tools\adb.exe' with args: ["-P",5037,"-s","0024804552","forward","--remove","tcp:12323"]
[Chromedriver] Spawning chromedriver with: C:\Users\larissa\AppData\Roaming\npm\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win\chromedriver.exe --url-base=wd/hub --port=8001 --adb-port=5037 --verbose
[debug] [JSONWP Proxy] Proxying [GET /status] to [GET http://ift.tt/2gQMKwC] with no body
[debug] [JSONWP Proxy] Got response with status 200: "{\"sessionId\":\"\",\"status\":0,\"value\":{\"build\":{\"version\":\"alpha\"},\"os\":{\"arch\":\"x86_64\",\"name\":\"Windows NT\",\"version\":\"10.0.14393\"}}}"
[debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://ift.tt/2ikiDhm] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.mydomain.app","androidUseRunningApp":true,"androidDeviceSerial":"0024804552"}}}
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"75a149fdaecee4b0aa8cdb918e40126a","status":100,"value":{"message":"chrome not reachable\n  (Driver info: chromedriver=2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41),platform=Windows NT 10.0.14393 x86_64)"}}
[debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://ift.tt/2ikiDhm] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.mydomain.app","androidUseRunningApp":true,"androidDeviceSerial":"0024804552"}}}
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"60405d7465025a41691e55604ad015f6","status":100,"value":{"message":"chrome not reachable\n  (Driver info: chromedriver=2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41),platform=Windows NT 10.0.14393 x86_64)"}}
[debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://ift.tt/2ikiDhm] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.mydomain.app","androidUseRunningApp":true,"androidDeviceSerial":"0024804552"}}}
[debug] [AndroidBootstrap] Emitting alert message...
[debug] [AndroidBootstrap] [BOOTSTRAP LOG] [debug] Emitting system alert message
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"5e2a64b719375fbe9ab991e2196061cd","status":100,"value":{"message":"chrome not reachable\n  (Driver info: chromedriver=2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41),platform=Windows NT 10.0.14393 x86_64)"}}
[debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://ift.tt/2ikiDhm] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.mydomain.app","androidUseRunningApp":true,"androidDeviceSerial":"0024804552"}}}
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"5e2a64b719375fbe9ab991e2196061cd","status":100,"value":{"message":"chrome not reachable\n  (Driver info: chromedriver=2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41),platform=Windows NT 10.0.14393 x86_64)"}}
[debug] [JSONWP Proxy] Proxying [POST /session] to [POST http://ift.tt/2ikiDhm] with body: {"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.mydomain.app","androidUseRunningApp":true,"androidDeviceSerial":"0024804552"}}}
[debug] [JSONWP Proxy] Got response with status 200: {"sessionId":"4f7d535ec2da981db3699553ee2b2b11","status":100,"value":{"message":"chrome not reachable\n  (Driver info: chromedriver=2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41),platform=Windows NT 10.0.14393 x86_64)"}}
[Chromedriver] Chromedriver exited unexpectedly with code null, signal SIGTERM
[debug] [Chromedriver] Changed state to 'stopped'
[Chromedriver] Error: chrome not reachable
  (Driver info: chromedriver=2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41),platform=Windows NT 10.0.14393 x86_64)
    at Chromedriver.callee$2$0$ (../../lib/chromedriver.js:197:15)
    at tryCatch     (C:\Users\larissa\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke]     (C:\Users\larissa\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next]     (C:\Users\larissa\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
    at GeneratorFunctionPrototype.invoke     (C:\Users\larissa\AppData\Roaming\npm\node_modules\appium\node_modules\    babel-runtime\regenerator\runtime.js:136:37)
 Error: chrome not reachable
  (Driver info: chromedriver=2.30.477700     (0057494ad8732195794a7b32078424f92a5fce41),platform=Windows NT 10.0.14393 x86_64)
    at Chromedriver.callee$2$0$ (../../lib/chromedriver.js:197:15)
    at tryCatch     (C:\Users\larissa\AppData\Roaming\npm\node_modules\appium\node_modules\    babel-runtime\regenerator\runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (C:\Users\larissa\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (C:\Users\larissa\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
at GeneratorFunctionPrototype.invoke (C:\Users\larissa\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
[MJSONWP] Encountered internal error running command: Error: chrome not reachable
  (Driver info: chromedriver=2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41),platform=Windows NT 10.0.14393 x86_64)
    at Chromedriver.callee$2$0$ (../../lib/chromedriver.js:197:15)
    at tryCatch     (C:\Users\larissa\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:67:40)
    at GeneratorFunctionPrototype.invoke [as _invoke]     (C:\Users\larissa\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:315:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next]     (C:\Users\larissa\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:100:21)
    at GeneratorFunctionPrototype.invoke (C:\Users\larissa\AppData\Roaming\npm\node_modules\appium\node_modules\babel-runtime\regenerator\runtime.js:136:37)
[HTTP] <-- POST /wd/hub/session/3cab9d65-e952-4d96-9a17-0d5a474c62ec/context 500 253000 ms - 315
[HTTP] --> DELETE /wd/hub/session/3cab9d65-e952-4d96-9a17-0d5a474c62ec {}

In-App Purchase items are empty

I have a new project that developed 3 months ago. It has tested using TestFlight up to v1.0 build#11. Now, my customer requests adding IAP items in the app. I've setup all items on Store then tried to fetch all valid items (10 items), but the response.products always empty, all items are invalid.

I've tried both dev & ad_hoc provisioning. Remove then install app several times. But I've got no luck. Do I need generate new provisioning after adding API items and API feature?

Android Integration test reading a file from memory

I've a MVP architecture and in one Presenter I want to test a method to retrieve a Bitmap from memory

the method is along those lines

public Bitmap getBitmap(Context context, Uri uri) {
...
try {
    final InputStream input = context.getContentResolver().openInputStream(uri);
    bitmap = BitmapFactory.decodeStream(input, null, options);
    input.close();
    }
...
}

Now I'm not really familiar with the new Android Test Suite, and I don't want to use (if possible) external libraries like Robolectric, so I am a bit at loss on how to proceed...

My thoughts were to go for an instrumentation test since I depend on the Android component Context

@Test
public void getScreenshot() {
    final Uri uriBitmap = Uri.parse("testFile.jpg");
    final Context context = InstrumentationRegistry.getTargetContext();

    final Bitmap retrieved = presenter.getBitmap(context, uriBitmap);
    assertEquals(retrieved, preInjectedTestFile.jpg)
}

but then I am not sure how can I "inject" a testFile.jpg in the file system for the duration of the test... Moreover I'm not sure if the Context I am using is the same one of the hosting app or a test one, which would be better not to mess around with the "official" app memory

CMake - Automatically build test executable and find dependencies

I have a problem which can be solved in different ways but before starting writing any solutions I wanted to ask your opinion on the subject.

I have a server with a huge code base and since testing is non-existent I wanted to write some tests for it.

The idea is to split different test suites into different executable. So one test file will basically cover a single module.

I also want to automatically build one executable per test file.

Now I could recursively loop over all the files, remove the .cpp extension and add a new executable with the same name as the file. The problem is that I need to include the hpp/cpp files from the server into the executable as well since it is a dependency.

Is there a way I could automatically detect dependencies and add them to the test executable?

Adding all the files for every single executable takes months to compile.

Thanks in advance

How can the codeception get the text from alert in yii2?

I've the problem. I want to get some texts from alert that created by yii2 when the input text was blank. So here is test case on codeception (functional):

public function submitEmptyForm(\FunctionalTester $I)
    {
        $I->submitForm('#contact-form', []);
        $I->expectTo('see validations errors');
        $I->see('Contact', 'h1');
        $I->see('Name cannot be blank');
        $I->see('Email cannot be blank');
        $I->see('Subject cannot be blank');
        $I->see('Body cannot be blank');
        $I->see('The verification code is incorrect');
    }

And I ran that code, but I found the error in line:

$I->see('Name cannot be blank');

When I spec the code with inspect element, Here's the alert that I got:

<p class="help-block help-block-error">Name cannot be blank.</p>

How can I get the alert text when the doesn't have name or id ? I read "How to call element in codeception" in codeception.com, you should be called by name or id.

Jmeter-Ant xslt-report: BUILD FAILED Test.jtl does not exist error although i have Test.jtl

I am trying to run my Test.jmx file through below ant cmd: C:\apache-ant-1.10.1-bin\bin>ant

I get the following error:

C:\apache-ant-1.10.1-bin\bin>ant
Buildfile: C:\apache-ant-1.10.1-bin\bin\build.xml

run:
     [echo] funcMode = false
   [jmeter] Executing test plan: C:\apache-ant-1.10.1-bin\bin\Test.jmx ==> C:\apache-ant-1.10.1-bin\bin\Test.jtl

_message_xalan:

xslt-report:

BUILD FAILED
C:\apache-ant-1.10.1-bin\bin\build.xml:124: input file C:\apache-ant-1.10.1-bin\bin\Test.jtl does not exist

Total time: 4 seconds

C:\apache-ant-1.10.1-bin\bin>

This is the error that i see

Build.xml:

  <target name="xslt-report" depends="_message_xalan">
        <tstamp><format property="report.datestamp" pattern="yyyy/MM/dd HH:mm"/></tstamp>
        <xslt
            classpathref="xslt.classpath"
            force="true"
            in="${testpath}/${test}.jtl"
            out="${testpath}/${test}.html"
            style="${basedir}/jmeter-results-detail-report${style_version}.xsl">
            <param name="showData" expression="${show-data}"/>
            <param name="titleReport" expression="${report.title}"/>
            <param name="dateReport" expression="${report.datestamp}"/>
        </xslt>
    </target>

Should i add the path of test.jtl here?

Thanks in advance.