This topic explains how to configure C++test to compute authorship and assign quality tasks across the team.
Sections include:
There are typically many different team members working on a development project throughout the SDLC—from developers of application logic, to developers of the Web interface, to QA testers verifying end-to-end processes and transactions.
Using technologies ranging from peer review workflow automation, to static analysis, to unit testing, to runtime error detection, to SOA policy enforcement, to functional testing of individual SOA components as well as end-to-end test scenarios, C++test generates quality tasks for the various team members to perform. These tasks can then be assigned to the appropriate team members based on manual assignments or automatically-detected authorship data.
This task assignment is used to:
For developers, code authorship data can affect how much code is tested and which test results that are shown in each developer’s Quality Tasks view.
By changing a Test Configuration’s Scope settings, you can configure tests to cover only files or lines that you authored, or only files or lines that you modified after a specified date. Moreover, if the Test only files/lines authored by [your_username] Scope option is set for the Test Configuration used for a test, the Quality Tasks view will show only testing tasks from code that you authored and any additional tasks that were reassigned to you.
For QA, C++test can assign tasks based on source control data in a number of ways:
If you have added source files to a project in the C++test environment, you can see the team member assigned to a particular line of that source file, as well as information about when it was last modified:
Note that if you are not using source control data to calculate task ownership, the message will show modification information for the file (rather than for the specific line selected). |
C++test can assign error ownership according to source control data (from supported source control systems), the @author Javadoc tag, xml mapping files (direct file-to-author mappings), and/or the current local user.
If you use multiple sources to determine authorship, authorship priority is determined by reading your settings in the Preference panel’s Scope and Authorship page from top to bottom (source control first, @author tags second, a direct mapping file next, current user last). However, if one of the selected options does not determine an author (for instance, the @author tag was selected but the file does not have an @author tag), C++test determines authorship based on the next option selected. If C++test still fails to determine an author, the user is set as "unknown". Likewise, if none of these options is selected, the user is set as "unknown."
If you configure C++test to use both source control and @author tags for authorship computation, source control will be checked whenever possible, and @author will be used for projects and files which are not under source control.
If you choose to use the current local user, the local user will be considered the author and the local modification time will be considered the last modification time.
C++test assigns authorship and tasks as follows:
To see the author assigned to a particular line of source code, as well as information about when it was last modified:
Note that if you are not using source control data to calculate authorship, the message will show modification information for the entire file (rather than for the specific line selected). |
Authorship computation settings can be specified:
To use GUI controls to change authorship computation:
For details on how to specify authorship through settings, see Configuring Settings.
If you want to directly specify which authors are responsible for which files (rather than have authorship calculated automatically, you can specify file-to-author mappings. These mapping can be automatically configured once, then shared across the team using the auto-configuration process described in C/C++test Configuration Overview.
To directly specify how you want particular files or sets of files assigned:
src/**/Test* - assigns all files in directory "src" whose name starts with "Test" (e.g., "src/some/other/dir/TestFile.c")
Place the most general paths at the end of the mapping. For example, /ATM/** path is the last here because it is the most general: /ATM/other/** user 2 /ATM/** user 3 This assigns |
Alternatively, you can direct C++test to use the exported XML file by either:
scope.xmlmap=true, scope.xmlmap.file=[file],
and scope.mappings.location
properties (via the -settings
option described in Configuring Settings and [Parasoft Product Name] User’s Guide> Setup and Testing Fundamentals> Running Tests> Running Tests from the Command Line Interface. Note that this will override any authorship settings specified in the GUI.A sample XML authorship mapping file follows:
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE authorship (View Source for full doctype...)> <authorship> <!-- assigns all files named: "foo/src/SomeClass.java" to "author1" --> <file author="author1" path="foo/src/SomeClass.java" /> <!-- assigns all files whose names starts with any character (except /) and ends with "oo/ src/SomeClass.cs" to "author2" --> <file author="author2" path="?oo/src/SomeClass.cs" /> <!-- assigns all *.c files in any directory to "author3" --> <file author="author3" path="**.c" /> <!-- assigns every file whose path has a folder named "src" to "author4" --> <file author="author4" path="**/src/**" /> <!-- assigns all files located in directory "src" to "author5" --> <file author="author5" path="src/**" /> <!-- assigns all files in directory "src" whose name starts with "Test" i.e. "src/some/ other/dir/TestFile.java" to "author6" --> <file author="author6" path="src/**/Test*" /> </authorship> |
You can use a script to generate an XML mapping file from a source control system. The following example Perl script demonstrates how to generate an authorship mapping file from Git. If you are using a different source control system, make the appropriate modifications.
#!perl ############################################################ # GetAuthors.pl # Sample script to generate file --> author mapping. # Note that this is usually run only once, when you first # deploy C++test . # # This script assumes that you have a list of all the files in the # project. For example, such a list can be obtained on windows # by using "dir /s/b *.c" for c files. ############################################################ sub GetAuthor ############################################################ # Gets the author (person who last modified the file) for # the input file. ############################################################ { my $fileName = shift(@_); return `git log --pretty=format:"%an" -1 $fileName`; } print "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; print "<mapping>\n"; ############################################################ # AllCFiles.txt has a list of all the c files in the # project. The following loop iterates through all the # files and assigns owners to each. ############################################################ open(FILELIST, "<AllCFiles.txt") || die "Could not open AllCSFiles.txt"; while (<FILELIST>) { chop; my $fileName = $_; my $author = GetAuthor($fileName); if ($author eq "") { $author = "DontKnow"; } print "<file path=\"$fileName\" "; print "author=\"$author\" />\n"; } print "</mapping>\n"; |
By default, C++test assumes that each username value it detects (e.g., based on source control data, the system’s local user settings, @author tags, direct mapping files, imported scanner.properties files) is the code author’s username, and that the related developer’s email is [username]@[mail_domain].
However, in some cases, you might want to map the detected username to a different username and/or email address. For example:
These authorship settings can be automatically configured once, then shared across the team using the auto-configuration process described in C/C++test Configuration Overview.
If the appropriate authorship settings ARE NOT already set from the auto-configuration process—or if you want to change/override the imported settings—you can map the default user value detected to a different username and/or email address as follows:
If your C/C++test installation is connected with DTP, C/C++test automatically displays a list of suggestions when you start typing a team member’s name or email address. For example, when you type "a" to specify the name of the author, you can conveniently select the author from a list of usernames that start with "a". This applies to all of the UI elements where you can enter a team member’s name or email address (for example, email notifications, reassigning tasks, etc.). If the username or email address is not present in the DTP database, C/C++test displays a warning message. |
You can also specify the author mappings in a settings file (from the command line or in the C++test preferences stored on DTP). To do this:
For example:
|
You can determine whether author values are treated as case sensitive or case insensitive. This case sensitivity setting applies to author values in:
The case sensitivity setting here should match the case sensitivity setting in DTP. By default, DTP is case sensitive. For details on configuring case sensitivity in DTP, see the DTP User’s Guide.
The case sensitivity setting determines whether multiple variations of the same user name will be treated as one user or multiple users, For example:
Case insensitive mode is especially helpful when teams use an external database where the case of the user names is not significant. If the username david
is stored as DAVID
in the database and you are in case sensitive mode, tasks imported for DAVID
will not be matched up to david
.
You can set case sensitivity settings in the Preferences panel. To disable set case sensitivity, go to Parasoft> Authors and enable the Ignore case of user names in Parasoft Test platform option. With this option enabled, C/C++test assumes that usernames that differ only in casing are identical (for example "John" and "john" are considered to indicate the same user).
You can also configure case sensitivity with the settings option authors.ignore.case=true|false
. For details on settings options, see Configuring Settings.
If you and/or your team members work with multiple source control system, but use the same login for all source control systems, start the product as follows to ensure accurate authorship computation from source control:
cpptest -J-Duser.name=your_username ...
eclipse .... -vmargs -Duser.name=your_username
If you are using "local user" data to determine authorship, C/C++test uses by default the local user settings defined on the machine. To configure a different username, go to the top-level Parasoft Preferences page, disable the Default option, and enter the name you want to use in the User name field.