Skip to content

Unit and UI testing of ClimApp

Henriette Steenhoff edited this page May 16, 2019 · 3 revisions

Unit tests (functionality)

Basic test structure

test('description of what test is doing', () => {
  expect(<function to test>).toBe(<expected result>);
});

Example

test('Temperature is 12 degrees celcius when input unit is "SI" and temperature is 12 degrees', () => {
  expect(dash.getTemperatureValueInPreferredUnit(12, "SI")).toBe(12);
});

Path to code that needs testing:

ClimApp/cordova/climapp/www/js*

Path to tests:

ClimApp/cordova/climapp/www/js/test*

Run tests

npm run test

UI tests (integration)

General test structure

Appium lets you create a flow of actions to be performed in sequence. When you run the test it checks that all actions can be performed and fails otherwise. Below is added the navigation flow to move from the dashboard to the settings, choosing feedback and inputting some data which will be sent as feedback. Appium uses the id tags of the different elements in the code to navigate.

 appDriver.init(config.android19)
    .sleep(3000)
    .elementById('settings_nav')
    .click()
    .elementById('settings_feedback')
    .click()
    .elementById('1star1')
    .click()
    .elementById('2star2')
    .click()
    .elementById('3star3')
    .click()
    .elementById('feedback_text')
    .sendKeys('Automated testing sequence added!')
    .elementById('feedback_button')
    .click()
    .sleep(3000)
    .quit();

Test automation:

Framework: Jenkins Credentials: ask Henriette for them

Basically, when a new commit is added to master, the project will be built and all tests in project will be run. If tests are failing the developers will be made aware of where the code is failing and can fix it right away.

Clone this wiki locally