Skip to content
This repository has been archived by the owner on Sep 4, 2019. It is now read-only.

User Guide

Travis Allen edited this page May 21, 2013 · 3 revisions

User Guide

Framework Installation Into a Project

Steps

  1. Right click on a project in the Project Explorer view
  2. Select Install Unit Tests from the Unit Tests menu

Structure

We install our framework into a unittests folder at the root of the project. All files belonging to this framework are underneath this folder.

Framework Uninstall From a Project

Steps

  1. Right click on a project in the Project Explorer view
  2. Select Uninstall Unit Tests from the Unit Tests menu
  3. If you want to permanently delete the unittests folder select Yes, otherwise click No to leave the folder on the file system (but remove the Momentics link to our plugin) or Cancel to stop the uninstall.

Using the Plugin

Description

To make life easier for the developer we have created a simple to use interface which allows the user to create, view, and edit tests quickly and easily.

Layout

Underneath a project with the Unit Test Framework installed there will be a new node called Unit Tests. There are 4 nodes below this:

  1. Tests
  2. Support Files
  3. Code Coverage
  4. Mocks

![Screenshot showing the Unit Testing nodes in the Project Explorer](images/Project Explorer Initial.png)

Tests

This node provides an easy way to view classes that exist in the project and any unknown test files that do not match up to any known class. Each node at this level contains a name and a number of tests written for it. There are two types of nodes at this level:

  1. Class Nodes
  2. Unknown Nodes

Right clicking on the Tests node allows the user to create new unknown test source files.

Class Nodes

The project is constantly scanned to find all known classes. A class node is created for each. Associated to each node is a test file named test_<ClassName>.cpp inside the framework folder. Double clicking on this node opens this associated test file if it exists. If it does not exist the test file is created for you and pre-populates the file with:

  1. the gmock/gmock.h header include
  2. the inclusion for the header file defining this class
  3. a test fixture named <Class>Test
  4. an empty sample test to start with

Unknown Nodes

Any source files inside the test framework folder that do not correspond to a known class in the project are listed as an unknown node. Double clicking on these nodes will open the unknown test file.

Support Files

Any support header/source files in the test framework folder are listed here. By default there is one item which corresponds to a source file containing the main() entry point to set up the testing framework. The user can right click on this node to create a new header or source file to add their own helper class/methods to be re-used across test files.

Code Coverage

This node is used to open the code coverage results of the last executed unit test run. Double clicking on it opens the gcov plugin to display the code coverage in a user-friendly manner. In this gcov view you can double click on any file listed to see a highlighted view of the file showing each line in the file that has been executed or not.

![Screenshot showing the Code Coverage view](images/Code Coverage.png)

Mocks

This node allows the user to right click on it to update to the latest BB10 Mocks. A notification arrow will appear when the plugin detects the mock files are out of date. Since these mocks are ever-evolving it may be prudent to update to the latest mocks when an issue is encountered -- it could be it has already been fixed!

Configuring the Plugin

Pre-requisite Locations

The plugin attempts to configure itself by looking in certain default locations for the prerequisites. The user can open Window -> Preferences and navigate to Blackberry -> Unit Testing. On this preferences page the user is required to select the location of the CMake executable, qmake executable, and on Windows the MinGW installation folder and the MSYS installation folder.

Automatic Pre-requisite Installation (Windows Only)

The Unit Testing plugin can now install the pre-requisites for you with the click of a button. In Window -> Preferences -> Blackberry -> Unit Testing there is a button to install the pre-requisites for you. Note that this does not update your PATH variable with the MinGW/MSys bin folders which is a requirement for the build to succeed.

For this option to be available you must install the com.bb.extensions.plugin.unittests.dependencies plugin feature.

Building the Unit Tests

To build the unit tests the user must switch to the Unit Tests build configuration. The user can then build the project as per normal.

Running the Unit Tests

Launching the Tests

To run the unit tests there is a Run Configuration automatically configured for the user. This configuration is listed under the C/C++ Unit category as <Project Name> Unit Tests. Running this configuration will execute the tests and present the user with a graphical window from the CDT Tests Runner plugin showing the results of each test run.

Viewing the Results

After Launching the Tests a window appears showing a graphical representation of the tests. For each and every test that was run you can view the pass/fail status as well as the failure reason.

![Screenshot showing the results of Launching the Tests](images/Results Window.png)

Current Limitations

  1. We only look in two locations for classes to test: src and include (and all sub folders). If your project uses a different structure the plugin will not find your classes.