Guide for the Reference Projects
Introduction
We create reference projects to demonstrate how to use Tellurium for your own testing project. In the reference projects, we use Tellurium project web site as an example to illustrate how to write real-world Tellurium tests. The reference projects only use tellurium jar files and there are two sub-projects at the time of writing
- tellurium-junit-java
- tellurium-testng-java
Basically, the two sub-projects are the same and the only difference is that tellurium-junit-java uses JUnit 4 and tellurium-testng-java uses TestNG. Hence, here we only focus on the tellurium-junit-java project.
The tellurium-junit-java project illustrates the following usages of Tellurium:
- How to create your own Tellurium testing project using tellurium jar files.
- How to create your own UI Objects and wire them into Tellurium core
- How to create UI module files in Groovy
- How to create JUnit tellurium testing files in Java
- How to create and run DSL scripts
- How to create Tellurium Data Driven tests
- How to configure Tellurium with the configuration file TelluriumConfig.groovy
- Ant build script
- Maven support
- Support Eclipse, NetBeans, and IntelliJ IDEs
Check out and Setup the reference project in IDEs
The tellurium-junit-java reference project is at SVN trunk and the URL is:
http://aost.googlecode.com/svn/trunk/reference-projects/tellurium-junit-java
We have already included all Eclipse, NetBeans, and IntelliJ project files in the project code base. What you need to do is just check out the code and twist a bit about the settings.
For detailed step-by-step directions, please see
- Eclipse Project Setup
- NetBeans Project Setup
- IntelliJ Project Setup
Data Driven Testing
We use Tellurium Issue page as the data driven testing example, we define tests to search issues assigned to a Tellurium team member and use the input file to define which team members we want the result for.
We first define a TelluriumIssuesModule class that extends TelluriumDataDrivenModule class and includes a method "defineModule". In the "defineModule" method, we define UI modules, input data format, and different tests. The UI modules are the same as defined before for the Tellurium issue page.
The input data format is defined as
``` fs.FieldSet(name: "OpenIssuesPage") { Test(value: "OpenTelluriumIssuesPage") }
fs.FieldSet(name: "IssueForOwner", description: "Data format for test SearchIssueForOwner") { Test(value: "SearchIssueForOwner") Field(name: "issueType", description: "Issue Type") Field(name: "owner", description: "Owner") } ```
Here we have two different input data formats. The "Test" field defines the test name and the "Field" field define the input data name and description. For example, the input data for the test "SearchIssueForOwner" have two input parameters "issueType" and "owner".
The tests are defined use "defineTest". One of the test "SearchIssueForOwner" is defined as follows,
``` defineTest("SearchIssueForOwner") { String issueType = bind("IssueForOwner.issueType") String issueOwner = bind("IssueForOwner.owner") int headernum = getCachedVariable("headernum") int expectedHeaderNum = getTableHeaderNum() compareResult(expectedHeaderNum, headernum)
List<String> headernames = getCachedVariable("headernames") String issueTypes = getCachedVariable("issuetypes") String issueTypeLabel = getIssueTypeLabel(issueTypes, issueType) checkResult(issueTypeLabel) { assertTrue(issueTypeLabel != null) } //select issue type if (issueTypeLabel != null) { selectIssueType(issueTypeLabel) } //search for all owners if ("all".equalsIgnoreCase(issueOwner.trim())) { searchForAllIssues() } else { searchIssue("owner:" + issueOwner) } ...... } }
```
As you can see, we use "bind" to tie the variable to input data field. For example, the variable "issueType" is bound to "IssueForOwner.issueType", i.e., field "issueType" of the input Fieldset "IssueForOwner". "getCachedVariable" is used to get variables passed from previous tests and "compareResult" is used to compare the actual result with the expected result.
The input file format looks like
``` OpenTelluriumIssuesPage