GTest Runner
Sample Aurora OS application that demonstrates the use of gtest library to write unit tests.
Terms of Use and Participation
The source code of the project is provided under the license, that allows it to be used in third-party applications.
The contributor agreement documents the rights granted by contributors to the Open Mobile Platform.
For information about contributors see AUTHORS.
Code of conduct is a current set of rules of the Open Mobile Platform which informs you how we expect the members of the community will interact while contributing and communicating.
Project Structure
The project has a common structure of an application based on C++ and QML for Aurora OS. It uses app directory for the main application resources and tests for unit testing.
- ru.auroraos.GoogleTest.pro file describes the general project structure for the qmake build system.
-
app subproject contains application template.
- app.pro file describes the app subproject structure for the qmake build system.
- icons directory contains application icons for different screen resolutions.
-
qml directory contains the QML source code and the UI resources.
- cover directory contains the application cover implementations.
- pages directory contains the application pages.
- ru.auroraos.GoogleTest.qml file provides the application window implementation.
-
src directory contains the C++ source code.
- gtest-example.cpp file is the application entry point.
- testclass.cpp file contains functions that will be tested.
- translations directory contains the UI translation files.
- ru.auroraos.GoogleTest.desktop file defines the display and parameters for launching the application.
-
tests subproject contains unit testing template.
- gtest_dependency.pri file describes the dependencies required for unit testing.
- tests.pro file describes the tests subproject structure for the qmake build system.
- tst_testclasstest.h file contains unit tests.
- main.cpp file is the entry point for running tests.
- googletest directory of the GTest library.
- rpm directory contains the rpm-package build settings.
Compatibility
The project is compatible with all the supported versions of the Aurora OS.
To work with tests on a device, you need to disable rpm validator for the test package.
NB At the application development stage, it is possible to manually disable rpm validator (package validation). In this case, the system does not issue further reminders. Please note that unvalidated packages may be blocked by the system during installation. This may lead to disruption of the start of industrial operation.
Building an application in the Aurora SDK
The application is built in a standard way through the Aurora SDK via the build configuration panel.
During the build process, two separate RPM packages are created: one for the graphical application and one for unit testing. This is necessary for the independent deployment of the app and tests subprojects and separate dependency management. The second RPM package is required to run tests and does not include any graphical elements that would be displayed on the target device.
Testing in the Aurora SDK using Google test
To perform unit testing, you need to run the compiled project by selecting the "tests" running configuration. After that, main.cpp initializes GoogleTest and runs all the declared tests.
The test results will be displayed in the standard output of the application.
In this example, the unit tests are written in the tst_testclass_test.h file, and the functions being tested are located in the testclass.cpp file. The Google Test run is located in main.cpp.
To write a new test, you need to:
- Connect files of tested classes and functions from app to tests.pro
- Create .cpp file in tests project
- Write tests according to the googletest specification