This section provides an example Report, which shows how to retrieve test case results and how to display them depending on their status.
The following code snippet shows the frame for a Groovy script with the required imports. The code to retrieve the data must be implemented in the execute method. A more detailed description of the Klaros-Testmanagement API can be found in de.verit.klaros.core.model
import de.verit.klaros.scripting.*;
import de.verit.klaros.core.model.*;
import java.util.*;
public class TestScript implements KlarosScript {
public void execute(KlarosContext context) {
...
}
}
The next step in the data retrieval process is to actually get the required data. The following code snippet shows how to build a query string and how to get the data.
StringBuffer query = new StringBuffer();
query.append("select tcr from KlarosTestCaseResult tcr");
List<?> tcr = context.executeQuery(query.toString());
The data is returned in a List object that must be stored in the context so that it can later
be accessed from the report template. The code snippet below shows how to store the list in the context.
For more information on building queries please consult the HQL documentation.
context.add("results", tcr);
The List object is stored in the context with the name "results" and can be accessed from the report template
by this name. If more data is required, execute more queries to retrieve the data or process the already retrieved data
and store the processed data in the context with a different name.
![]() | Note |
|---|---|
|
It is possible to store more than one object in the context. Just use a different name for each object. |