JSAFS Annotations
Automatic Java dependency injection and dynamic test execution.
This document discusses assets provided by the SAFS Windows Release. However, the details of how to configure and use these features are similar for all SAFS installations.
%STAFDIR%
Refers to the installation directory of STAF.
WIN Default: C:\STAF
UNX Default: (future)
%MYTEST%
Refers to the sample Eclipse Project provided.
Default: %SAFSDIR%\samples\eclipse\MyTest
We will assume Eclipse is being used for Java development. But other Java development environments can be used and configured similarly.
\com\sas\test \Datapool\ \Bench\ \Test\ \Logs\ \Dif\ test.ini
Some of the subdirectories of Datapool may not be present
That is OK. Missing directories should be automatically created at runtime.
You should note the [SAFS_ENGINES] entries for SmartBear's TestComplete and IBM Rational Functional Tester are intentionally commented out (disabled).
This sample test will be using the internal AutoIt Engine for test execution.
%SAFSDIR% /lib/ SAFS.jar
JavaDoc location: http://safsdev.sourceforge.net/doc
%SAFSDIR% /lib/ safsmodel.jar
JavaDoc location: http://safsdev.sourceforge.net/doc
In the Run Menu->Run Configurations Dialog:
New Java Application Launch Configuration: Name: Run MyTest Main Tab: Project: MyTest Main class: com.sas.test.MyTest Press Apply to commit these changes. Arguments Tab: VM Arguments: -Dsafs.project.config="./test.ini" Ensure "Working Directory" is set to ${workspace_loc:MyTest} Press Apply to commit these changes. JRE Tab: Runtime JRE: If the Project JRE is not the (SAFS) JRE, then Execution environment: must point to the <SAFS\jre> (If the SAFS\jre is NOT listed, you will need to add it via "Installed JREs".) Press Apply to commit these changes. Press Close to finish the Run Configuration settings.
This is a standard text-based SAFS App Map file.
AppMap files are, essentially, in Windows INI file format.
You should notice that the Datapool \ App.map text file and the AppMap.java file have references to the same things.
In fact, you MUST NOT edit the AppMap.java file because it can be dynamically built for you from the text file.
Any manual edits you make to AppMap.java will be wiped out the next time it is dynamically generated.
In the Run Menu->Run Configurations Dialog:
New Java Application Launch Configuration: Main Tab: Name: Generate MyTest AppMap Project: MyTest Main class: org.safs.model.tools.ComponentGenerator Arguments Tab: Program Arguments: -in "./Datapool/App.map" -package "com.company.test" -out "./com/company/test" -name "AppMap" Ensure "Working Directory" is set to ${workspace_loc:MyTest} Press Apply to commit these changes. JRE Tab: Runtime JRE: If the Project JRE is not the (SAFS) JRE, then Execution environment: must point to the <SAFS\jre> (If the SAFS\jre is NOT listed, you will need to add it via "Installed JREs".) Press Apply to commit these changes. Press Close to finish the Run Configuration settings.
Be sure to Save your changes to the App.map text file.
You should find in the Package Explorer, and in the Editor Window, references to the UserID item you added will now appear in AppMap.java.
Review how the AppMap Components and Constants are used with the Runner to build SAFS tests.
Don't forget to HOVER the mouse over the Runner, the AppMap, and their associated items and methods to see the reference documentation for each one.
Carl Nagle, SAS Institute Project Manager, SAFSDEV Subscribe to appropriate Support Forums to review support archives and ask questons.