How do test scripts work?

What are GANT scripts?


Test scripts look like Groovy scripts, but are actually GANT scripts. GANT is a Groovy extension that implements the concepts of targets and dependencies. Targets are closures that can specify dependencies on other targets. GANT organizes the running of targets so that all dependencies are run in the proper order. While GANT is an ANT like build system using Groovy syntax (verses XML), GINT uses the GANT's target and dependency support as a general Groovy extension that makes Groovy scripting much easier. Code (targets) can be independently defined or generated and then be run in the order demanded by the dependency information. This makes it easier to organize code execution. Also, GANT's command line makes it possible to run one or more targets without any additional scripting to control process flow.


Key concepts


GANT scripts define targets that are later run by GANT target processing. So there are 2 phases:


  1. Definitional phase - Groovy code (outside of target definitions) is run. This code can do anything normally done by a Groovy script and can also dynamically create targets. The entire script is run as Groovy code and analysed for target definitions.
  2. Target run phase - targets are run according to the dependency rules defined by the targets


GINT testcases


GINT uses GANT's target mechanisms for running testcases. GINT generates a target for each testcase. It also generates grouping targets and other targets to control the running of testcases. GINT provides all the targets necessary for running the test, so normal test scripts don't need to explicitly code targets. This means GINT test scripts normally look like Groovy scripts. Of course, test scripts can also contain user defined targets. It also means that GINT test scripts have 2 phases:


  1. Definitional phase - testcases are defined. The entire Groovy/Gant script is run and this defines the testcases.
  2. Testcase run phase - testcases are run according to dependency information defined in the testcase together with GINT processing.


To see the targets defined for a test script, simply use the -p command line option.


Example


gant -f sample1.gant -p

 allTestcases  GINT: Run all testcases with setUp and tearDown.
 base          Testcase group
 commandList   GINT: List all commands that would be run.
 default       GINT: Run last failed or all testcases.
 failExample   Testcase: failExample
 failed        GINT: Run testcases that failed last run.
 final1        Testcase: final1
 finalize      GINT: Result summary
 help          GINT: Help summary.
 matchNames    GINT: Run testcases whose name contains match parameter.
 runTestcases  GINT: Run main testcases
 sample1       Testcase: sample1
 setUp         GINT: Run setUp testcases.
 setup1        Testcase: setup1
 tearDown      GINT: Run tearDown testcases.
 teardown1     Testcase: teardown1

Default target is default.