Feature - CSV Defined Testcases

Description

For some organizations and testing considerations, it is more desirable to have testcases defined in tables instead of code. While some level of testcase scripting may still be necessary, GINTtestcase definitions can come from CSV filesor database tables. GINT processes CSV files conforming to The Comma Separated Value (CSV) File Format.


Usage

  • CSV testcase definitions can be included in any GINT testcase
  • At least a short Groovy based test script is still required to run CSV based testcases
  • Groovy code can be used in any designated column, but is not required
  • The first row of the CSV file must be a row of column names
  • All columns necessary for a valid testcase definition must be present in the CSV file
  • Column names ending with _code are interpreted as Groovy code, the _code is stripped from the column name to form the parameter name
  • Column names ending with Closure are turned into Groovy closures with testcase being the only Closure parameter
  • inline column, if present, is also handled as a closure

Example

This example is from GINT's own integration test, so is a bit contrived as it was needed to test the capabilities. A more typical example would be command based with little or no Groovy code (smile).

csvTest.gant

includeTool << org.swift.tools.Gint           // test framework

gint.initialize(this) // required

gint.addFromCsv(fileName: gint.getResourceFile('test.csv'))  // file from the project's resource directory

gint.finalizeTest() // final preparations for running tests

test.csv

  • First line defines the testcase parameter names

    name, inline, someTest_code, level
    t1, assert 1 == 1
    t2, assert 1 == 2, , false
    t3, "def x = ""t3""
    return (testcase.name == x)"
    t4, "testcase.name; return true",
    t5, "assert (testcase.someTest instanceof List); assert testcase.someTest.size() == 2;", "['1', '2']"
    
    invalid will be ignored

Run

gant -f csvTest.gant

= = = = = =   csvtest started at Sat Sep 11 18:15:58 CDT 2010   = = = = = =

    [start] t1
    [start] t3
    [start] t4
    [start] t5
  [warning] Testcase 'invalid will be ignored' does not define cmd or inline code. 
  [warning] Ignoring testcase: [name:invalid will be ignored, expected:0]
   [ending] t1
 [complete] t1 - 0.071 secs

   [ending] t3
 [complete] t3 - 0.082 secs

   [ending] t4
 [complete] t4 - 0.053 secs

   [ending] t5
 [complete] t5 - 0.051 secs

     [info] Successful testcases  . . . . . . . . . . : 4    <<< TEST SUCCESSFUL
     [info] Not run testcases . . . . . . . . . . . . : 1
     [info] Deferred testcases  . . . . . . . . . . . : 1
     [info] Level of run  . . . . . . . . . . . . . . : 1
     [info] Deferred levels . . . . . . . . . . . . . : [false]
     [info] Total testcases . . . . . . . . . . . . . : 6
     [info] Elapsed run time  . . . . . . . . . . . . : 0.978 secs

= = = = = =   csvtest completed at Sat Sep 11 18:15:58 CDT 2010 = = = = = =

BUILD SUCCESSFUL
Total time: 2.04 seconds

© 2005 -2024 gint.org