Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Moodle Mobile 2 (Ionic 1) End To End Testing: Difference between revisions

From MoodleDocs
No edit summary
Line 5: Line 5:
This currently only covers testing on Android 4.4 onwards and Chrome. iOS testing is a work in progress.
This currently only covers testing on Android 4.4 onwards and Chrome. iOS testing is a work in progress.


* Install Chromium browser for development
Head to the root directory of your MM instance.
* Install Node.js(Don’t use node 4.0 or higher, there are incompatibilities with some of the packages we use. Please use v0.12.7 instead)
* Install the packages required for testing
* Install ionic
npm install (do not use the -g option)
** npm cache clean
** npm install -g cordova ionic
* Clone the code base into a local directory in your computer
** git clone https://github.com/moodlehq/moodlemobile2.git moodlemobiledirectory
** cd moodlemobiledirectory
** git pull
* Head to the root directory of your MM instance.
* Install the packages required for testing
** npm install (do not use the -g option)
** npm install -g bower
** npm install -g gulp
* Add the iOS and Android platforms and install the required Cordova plugins
** ionic platform add android@4.1.1
** ionic platform add ios@3.9.1
** ionic state restore
* Install bower globally and the required javascript files
** bower install
*  Run gulp’s default tasks (in order to create the build files)
** gulp
* Open the app in the browser
** ionic serve --browser chromium
* Install the Chrome webdriver
* Install the Chrome webdriver
** ./node_modules/protractor/bin/webdriver-manager update
./node_modules/protractor/bin/webdriver-manager update
* Make sure your checkout is up to date, all the cordova plugins are installed and the android platform is set-up. The following should be enough.
* Make sure your checkout is up to date, all the cordova plugins are installed and the android platform is set-up. The following should be enough.
** gulp
gulp
** ionic state restore
ionic state restore
** ionic build android
ionic build android


Once this is done, you will need to generate a protactor configuration file for the platform you intend to test the app on.
Once this is done, you will need to generate a protactor configuration file for the platform you intend to test the app on.
Line 44: Line 23:
* For Android
* For Android
** gulp e2e-build --target android --device abcdefg --version 4.4  
** gulp e2e-build --target android --device abcdefg --version 4.4  
* For Chrome
* For Chrome (browser)
** gulp e2e-build --target browser
** gulp e2e-build --target browser
By default the configuration file is saved at e2e/build/protractor.conf.js, should you wish to save the configuration file to re-use it later, you can use the argument --output <filename>.
Other arguments are available, you can find more about them using:
    gulp e2e-build -h
    gulp e2e-build --target android -h
    gulp e2e-build --target browser -h


== Running the suite ==
== Running the suite ==
Line 56: Line 43:
* Wait for the driver to be fully started
* Wait for the driver to be fully started
* Run Protractor  
* Run Protractor  
** moodlemobiledirectory/node_modules/protractor/bin/protractor ../../../e2e/build/protractor.conf.js
** ./node_modules/protractor/bin/protractor e2e/build/protractor.conf.js

Revision as of 08:39, 28 June 2016

Protractor is an end-to-end test framework for AngularJS applications. Protractor runs tests against your application running in a real browser, interacting with it as a user would.

Setting-up testing environment

This currently only covers testing on Android 4.4 onwards and Chrome. iOS testing is a work in progress.

Head to the root directory of your MM instance.

  • Install the packages required for testing
npm install (do not use the -g option)
  • Install the Chrome webdriver
./node_modules/protractor/bin/webdriver-manager update
  • Make sure your checkout is up to date, all the cordova plugins are installed and the android platform is set-up. The following should be enough.
gulp
ionic state restore
ionic build android

Once this is done, you will need to generate a protactor configuration file for the platform you intend to test the app on.

Generating Protractor config file

Protractor config file contains all the information for running the tests, as well as to provide the tests with information about the site being tested.

  • For Android
    • gulp e2e-build --target android --device abcdefg --version 4.4
  • For Chrome (browser)
    • gulp e2e-build --target browser

By default the configuration file is saved at e2e/build/protractor.conf.js, should you wish to save the configuration file to re-use it later, you can use the argument --output <filename>.

Other arguments are available, you can find more about them using:

   gulp e2e-build -h
   gulp e2e-build --target android -h
   gulp e2e-build --target browser -h

Running the suite

  • Run the ionic first
    • ionic serve -b -a
  • Start the web driver
    • For Android: ./node_modules/appium/bin/appium.js
    • For Chrome : ./node_modules/protractor/bin/webdriver-manager start
  • Wait for the driver to be fully started
  • Run Protractor
    • ./node_modules/protractor/bin/protractor e2e/build/protractor.conf.js