TPTP provides several automatable services which can be invoked from outside the context of the eclipse workbench. The services include test execution, test result interrogation and test result publication.
This help topic explains how to use the built-in TPTP automatable services to do the following:
The test execution service is provided for the programmatic launch, execution and generation of test results. Il servizio di esecuzione della verifica ingloba la funzionalità di esecuzione verifica esistente e rende obsoleti i metodi di esecuzione verifica autonomi correnti. Utilizzando il servizio di esecuzione della verifica, è possibile avviare le verifiche mediante un Eclipse indipendente da script ant, script shell e programmi arbitrari. È possibile eseguire più verifiche allo stesso tempo se la macchina dispone di memoria sufficiente (ciascuna esecuzione di servizio richiede un'istanza host di Eclipse separata). Anche se le verifiche sono in esecuzione su macchine remote mediante la distribuzione e le funzioni di esecuzione verifiche remote TPTP, le istanze host di Eclipse vengono eseguite sulla macchina dell'utente del servizio.
Consultare il materiale di riferimento relativo alle proprietà del servizio di esecuzione verifica supportate; le stesse proprietà sono valide per tutti gli adattatori di automazione client. Per gli script ant, viene fornito un insieme di semplici attività ant per impostare le proprietà del servizio e per eseguire il servizio. Per gli script shell, le proprietà vengono specificate nel paradigma della riga comandi previsto (utilizzando trattini per le proprietà seguiti da spazi e quindi dal un valore per l'istanza). Per i programmi Java, i jar del client di automazione verranno indicati come riferimento e utilizzati per impostare le proprietà e controllare l'esecuzione del servizio. Alcuni adattatori client potrebbero avere altre opzioni obbligatorie per quel particolare ambiente client (o offerte come funzioni extra da tale adattatore).
I componenti del servizio TPTP automatizzabile vengono aggiunti al pacchetto del plugin org.eclipse.hyades.execution rappresentato con tre file jar, codice XML in plugin.xml ed alcune voci nel file MANIFEST.MF.
tptp-automation-client.jar
(il bit di codice necessario per stabilire
il client del bus del servizio, avviare Eclipse se necessario ed eseguire i servizi indipendentemente; questo jar
verrà indicato come riferimento durante l'esecuzione delle verifiche dalla riga comandi e dagli script shell e
durante l'esecuzione delle verifiche da codice Java arbitrario).tptp-automation-server.jar
(il server di automazione TPTP,
caricato su richiesta come servizi, viene interrogato ed eseguito mediante il
framework, implementa il punto di estensione delle applicazioni Eclipse core, utilizzato come
broker e indicatore di posizione del servizio)ant-tptp.jar
(questo jar ha lo stesso contenuto di
tptp-automation-client.jar ma è stato ridenominato per congruenza con altre librerie di attività)Assicurarsi che ant sia correttamente installato se le verifiche devono essere eseguite esternamente ad un'istanza di Eclipse in esecuzione; per impostare questi parametri, fare riferimento alla documentazione di ant. In aggiunta all'installazione ant standard, copiare ant-tptp.jar nella directory ant lib insieme alle altre attività. If running inside of Eclipse, ant is already installed although be sure to include the ant-tptp.jar in the additional tasks tab of the ant launch configuration, or in the Global Entries section of the Ant Classpath preference page. Lo script ant di esempio integrato, riportato di seguito, è un esempio di script ant chiamato "test.xml" che esegue una verifica chiamata testA nella cartella unit-tests del progetto di verifica. Il progetto di verifica si trova nello spazio di lavoro specificato "d:\development\workspace" e l'istanza host di Eclipse è "d:\development\eclipse". Fare riferimento all'elenco delle proprietà supportate per altre combinazioni valide di proprietà.
L'esempio riportato di seguito utilizza l'attività di verifica TPTP anche se è possibile eseguire una verifica utilizzando l'attività di automazione TPTP. L'attività di automazione più generica è un'attività ant per l'esecuzione di servizi automatizzabili TPTP arbitrari in opposizione all'attività di verifica TPTP più specifica. L'attività di verifica è di tipo sicuro ed è stata specificamente creata per avviare il servizio di esecuzione della verifica. Nel pacchetto org.eclipse.hyades.automation.test della cartella di origine src-automation-client del plugin org.eclipse.hyades.execution, sono inclusi più esempi di script ant.
<project name="TPTP Ant Tasks Test Script" default="test" xmlns:tptp="antlib:org.eclipse.hyades.automation.client.adapters.ant"> <property name="eclipse.home" value="D:\development\eclipse"/> <description> This ant script tests the TPTP automation ant task client adapters and also can be used to test the underlying execution of TPTP automatable services via the TPTP automation server </description> <!-- Execute TPTP test suites --> <target name="test" description="Executes TPTP Test Suites using default TPTP Ant Tasks"> <!-- Execute a TPTP test suite using the test task and providing the workspace --> <tptp:test workspace="D:\development\workspace" project="tests" suite="unit-tests/testA.testsuite" synchronicity="synchronous"/> </target> </project>
Ensure that you have properly configured ant to run TPTP automatable services
(refer to the above section on running tests from ant.) The example below shows how
to the use the tptp:execution task to execute multiple tests, and how to use the
tptp:interrogation task to interrogate the results of those test executions.
Both of these ant tasks accept multiple ant filesets
and/or
filelists
, allowing you to use wildcards or to directly
specify multiple files as inputs to the tasks. In this example, we execute
all of the test suites in the TPTPJUnitTests project, and the set of
all resulting .execution files is returned to us as a filelist
in the ant variable that we supply (in this case "tptp.test.results".) We then
pass that filelist
as input to the tptp:interrogation service,
which will interrogate each of those execution files to determine an overall
verdict and will assign it to the ant variable that we supply (in this case
"tptp.test.verdict".)
<project name="TPTP Automatable Services Tutorial"
default="main" xmlns:tptp="antlib:org.eclipse.hyades.automation.client.adapters.ant"> <!-- Define common properties for all automatable services --> <property name="tptp.test.workspace" value="C:\eclipsecon\eclipse\workspace"/> <property name="tptp.test.project" value="TPTPJUnitTests" /> <property name="tptp.test.connection" value="tptp:rac://localhost:10002/default"/> <property name="tptp.automation.eclipse" value="C:\eclipseconwb_birt\eclipse" />
<!-- Define script-local properties, that vary by installation --> <property name="project.dir" value="${tptp.test.workspace}\${tptp.test.project}"/>
<target name="main" depends="test-execution, test-results-interrogation"/>
<!-- Execute test suites using default results name --> <target name="test-execution"> <echo message="Executing test suite..." /> <tptp:execution resultsrefid="tptp.test.results"> <fileset dir="${project.dir}"> <include name="**/*.testsuite"/> </fileset> </tptp:execution> </target>
<!-- Interrogate test suite results for verdict --> <target name="test-results-interrogation"> <echo message="Interrogating test suite results..." /> <condition property="tptp.test.success"> <tptp:interrogation verdictproperty="tptp.test.verdict"> <filelist refid="tptp.test.results"/> </tptp:interrogation> </condition> <echo message="The overall test result verdict is: '${tptp.test.verdict}'" /> </target>
</project>
Ensure that you have properly configured ant to run TPTP automatable services
(refer to the above section on running tests from ant.) The example below shows how
to the use the tptp:execution task to execute multiple tests, and how to use the
tptp:publication task to generate BIRT based reports from the results of those
test executions. The publication task also accepts multiple ant
filesets
and/or filelists
, allowing you to use
wildcards or to directly specify multiple files as inputs. In this example,
we execute all of the test suites in the TPTPJUnitTests project, and the set of
all resulting .execution files is returned to us as a filelist
in the ant variable that we supply (in this case "tptp.test.results".) We then
pass that filelist
as input to the tptp:publication service,
which will generate a TPTP execution report using the default report template
(TestExecution.rptdesign, found in the org.eclipse.tptp.test.report.birt plugin),
placing it in the specified location (in this case c:\temp\report.html.)
<project name="TPTP Automatable Services Tutorial"
default="main" xmlns:tptp="antlib:org.eclipse.hyades.automation.client.adapters.ant"> <!-- Define common properties for all automatable services --> <property name="tptp.test.workspace" value="C:\eclipsecon\eclipse\workspace"/> <property name="tptp.test.project" value="TPTPJUnitTests" /> <property name="tptp.test.connection" value="tptp:rac://localhost:10002/default"/> <property name="tptp.automation.eclipse" value="C:\eclipseconwb_birt\eclipse" />
<!-- Define script-local properties, that vary by installation --> <property name="project.dir" value="${tptp.test.workspace}\${tptp.test.project}"/> <property name="report.publication.location" location="c:/temp" />
<target name="main" depends="test-execution, test-results-publication"/>
<!-- Execute test suites using default results name --> <target name="test-execution"> <echo message="Executing test suite..." /> <tptp:execution resultsrefid="tptp.test.results"> <fileset dir="${project.dir}"> <include name="**/*.testsuite"/> </fileset> </tptp:execution> </target>
<!-- Publish test suite results report -->
<target name="test-results-publication"> <echo message="Publishing test suite results report..." /> <tptp:publication report="${report.publication.location}/report.html"> <filelist refid="tptp.test.results"/> </tptp:publication> </target>
</project>
You may customize the behavior of the tptp:publication task by specifying a different BIRT report template, for instance TabularReport.rptdesign found in the templates directory of plugin org.eclipse.tptp.test.report.birt. You may also customize the behavior by using the publish-testsuites publication service and providing test suites as the input to the publication service instead of test execution results files. If you use the publish-testsuites publication service and pass test suite files as input to the publication service, you must also specify a start and end date for the report window (which will be used to query the workspace to find all execution results within that time window.) The example below shows how to run a report on all of the test suites in the Test1 project, selecting every execution result from the past 60 days, and generating the report using the Tabular report design.
<project name="TPTP Automatable Services Tutorial"
default="main" xmlns:tptp="antlib:org.eclipse.hyades.automation.client.adapters.ant"> <!-- Define common properties for all automatable services --> <property name="tptp.test.workspace" value="C:\eclipsecon\eclipse\workspace"/> <property name="tptp.test.project" value="TPTPJUnitTests" /> <property name="tptp.test.connection" value="tptp:rac://localhost:10002/default"/> <property name="tptp.automation.eclipse" value="C:\eclipseconwb_birt\eclipse" />
<!-- Define script-local properties, that vary by installation --> <property name="project.dir" value="${tptp.test.workspace}\${tptp.test.project}"/> <property name="report.publication.location" location="c:/temp" /> <property name="tptp.publication.service" value="org.eclipse.tptp.test.report.birt.publish-testsuites"/>
<!-- Run the report --> <target name="main" depends="test-results-publication"/>
<target name="set-date-range"> <!-- Use standard ant tstamp mechanisms to specify the desired date range --> <!-- This example uses a range between today and 60 days days prior --> <tstamp> <format property="startDateTime" pattern="MM/dd/yyyy hh:mm aa" offset="-60" unit="day"/> </tstamp> <tstamp> <format property="endDateTime" pattern="MM/dd/yyyy hh:mm aa"/> </tstamp> </target>
<!-- Publish test suite results report --> <target name="test-results-publication" depends="set-date-range"> <echo message="Publishing test suite results report..." /> <tptp:publication report="${report.dir}/report.html" reportTemplateLocation="C:\TPTP_TestPass\ReportBuild\eclipse\plugins\org.eclipse.tptp.test.report.birt_4.2.0.v200605180959\templates\TabularReport.rptdesign" startDateTime="${startDateTime}" endDateTime="${endDateTime}" > <fileset dir="${project.dir}"> <include name="**/*.testsuite" /> </fileset> </tptp:publication> </target>
</project>
Le verifiche possono essere eseguite direttamente dalla riga comandi e dagli script shell con le proprietà di verifica trasformate in argomenti della riga comandi. Gli adattatori client di automazione TPTP forniscono un file .bat e un file .cmd da utilizzare in Windows e un file .sh da utilizzare nel sistema operativo Linux. È possibile specificare serie di argomenti lunghe e/o ripetere frequentemente gli stessi argomenti in un file di configurazione per minimizzare la quantità di immissioni necessaria per eseguire il servizio di verifica dalla riga comandi. L'adattatore client di automazione shell si manifesta come un file di testo (per il file batch o per lo script) e come un componente Java complementare (devono esistere entrambi) per eseguire verifiche dalla riga comandi. Tutti gli adattatori client di automazione TPTP forniti si trovano in tptp-automation-client.jar anche se ant-tptp.jar replica alcuni codici dell'adattatore nella forma di un ant jar (in tal modo il nome dell'attività TPTP jar rimane congruente con le altre attività ant disponibili).
Le proprietà del servizio di esecuzione verifica vengono impostate inserendo nei nomi delle proprietà in trattino come prefisso, e specificando anche la directory home o principale di Eclipse.
Le verifiche possono essere avviate da qualsiasi applicazione Java, infatti gli altri adattatori di automazione client, ad esempio gli adattatori ant e shell, utilizzano l'adattatore Java internamente per accedere al bus del servizio. L'unico requisito per l'esecuzione delle verifiche da codice Java è che tptp-automation-client.jar sia indicato correttamente come riferimento (in Eclipse questo vuol dire che la libreria si trovi nel percorso di generazione del progetto Java) e che siano applicati tutti i requisiti TPTP tipici, ad esempio agent controller deve essere in esecuzione.
L'adattatore di automazione Java fornisce un semplice API per l'esecuzione delle verifiche con tutte le proprietà specificabili contenute in un oggetto di proprietà Java standard. Di seguito è riportato un esempio per l'esecuzione della stessa verifica come introdotto nell'esempio di script ant precedente. Osservare che l'identificativo del servizio trasmesso per eseguire il metodo, è l'identificativo del servizio di esecuzione verifica TPTP (questo servizio supporta tutti i tipi di verifica TPTP di base); è anche possibile eseguire altri servizi automatizzabili, se disponibili, ma gli identificativi e le proprietà riportate nel codice seguente saranno diversi.
// Create the Java adapter associated with the specified Eclipse home AutomationClientAdapter automation = new AutomationClientAdapter ("d:\\development\\eclipse"); // Create and configure a properties object Properties properties = new Properties(); properties.setProperty("workspace", "D:\\development\\workspace"); properties.setProperty("project", "tests"); properties.setProperty("suite", "unit-tests/testA.testsuite"); // Execute the service named below using the configured properties automation.execute("org.eclipse.hyades.test.tools.core.execute", properties);
Argomenti correlati
Panoramica sul framework di servizi automatizzabili
Attività correlate
Avvio delle verifiche da
script e applicazioni
Riferimenti correlati
Proprietà del servizio di esecuzione verifica supportate
(C) Copyright IBM Corporation 2005,2006. Tutti i diritti riservati.