Skip to content

How to test the project

enmust edited this page Nov 2, 2017 · 1 revision

Before testing, make sure all the prerequisites are met.

How to run tests

Unit tests

Run

gradle test

gradle test will run all the tests that are located in a src/test folder. To exclude any file you don't want to run via this command, add exclude rule:

test {
     exclude "**/ee/ttu/geocollection/uiTests/*.class"
}

UI tests

Run the application locally

gradle bootRun

Then run

gradle testUI

Launching UI tests will require a headless browser called phantomJS. Both versions for Linux and Windows are currently included in the project, therefore no additional installation needed. UI tests also require Selenium, Selenide and GhostDriver. These dependencies are being loaded via gradle. Make sure build.gradle contains following dependencies:

testCompile group: 'org.seleniumhq.selenium', name: 'selenium-java', version:'3.4.0'
testCompile 'com.github.detro:ghostdriver:2.0.0'
testCompile 'com.codeborne:selenide:4.4.1'

gradle testUI task can also be configured in build.gradle

task testUI(type: Test) {
     scanForTestClasses = false
     include "**/ee/ttu/geocollection/uiTests/*.class"
     def phantomJsFilename = Os.isFamily(Os.FAMILY_WINDOWS) ? "phantomjs/phantomjs-2.1.1-windows/bin/phantomjs.exe" : "phantomjs/phantomjs-2.1.1-linux-x86_64/bin/phantomjs"
     systemProperty "phantomjs.binary.path", phantomJsFilename
}

gradle testUI command runs all the tests form uiTests folder. Path to phantomJS binary is chosen depending on the operating system.