static void dataDriver()

in DDT-Framework/src/main/groovy/ddt/framework/TestCaseUtils.groovy [283:415]


    static void dataDriver(TestCaseRunContext context, TestCaseRunner testRunner) {

	    // get objects from context
	    def testCase = (TestCase)context.testCase
		def testData = (TestData)context.currentTestData
		def variablesMapping = (VariablesMapping)context.variablesMapping
		def properties = (Properties)context.commonProperties

        testData.setCurrentRow(testCase.getPropertyValue(CURRENT_ROW_PROPERTY).toInteger())
		
		// Skip commented lines
		def gotoRow = testData.getNextRow()
		//log.info "${gotoRow} == ${testData.currentRow.toString()}"
		
		log.info "Process line: " + testData.currentRow.toString()

        // Set new value to testCase CURRENT_ROW_PROPERTY 
        testCase.setPropertyValue(CURRENT_ROW_PROPERTY, testData.currentRow.toString())

			//
			// ??? Handle on data object can be kept in context ???
			// context.currentDataObject = testData.getData()
			//
		
		// Parse test data
		Data data = testData.getData()

        if ( data != null ) {

            log.info "description = ${data.description}"

            // Resolve references to properties from config file and from SoapUI project in test data
            TestData.substitutePropertiesInRequest(data, properties)
		    
			def evalUtils = new EvalUtils()
			evalUtils.VARIABLES = variablesMapping.variablesMap			
			evalUtils.PRODUCT_VARIABLES = variablesMapping.productsMap			
			
            // Resolve variables in test data
            TestData.substituteVariablesInRequest(data, evalUtils.VARIABLES)

            // Resolve references to previously found products
            TestData.substitutesProductInData(data, evalUtils.PRODUCT_VARIABLES)
	
            // Get resource method & path
            def method = data.method
            log.info "method = ${method}"

            def resourcePath = data.resourcePath
            testCase.setPropertyValue(RESOURCE_PATH_PROPERTY, resourcePath)

            // Set expected results - response and status
            log.info "status = ${data.status}"
            testCase.setPropertyValue(STATUS_PROPERTY, data.status)

            log.info "contentType = ${data.contentType}"
            testCase.setPropertyValue(CONTENT_TYPE_PROPERTY, data.contentType)

            log.info "expectedAssertionResults = ${data.expectedAssertionResults}"
            testCase.setPropertyValue(EXPECTED_ASSERTION_RESULTS_PROPERTY, data.expectedAssertionResults)

            // Process response
            def previousExpectedResponse = getExpectedResponseFromTestCase(testCase)
            def previousActualResponse = getActualResponseFromTestCase(testCase)
	
            // Set request parameters for HTTP methods

            switch (method) {
			
                case HTTP_METHODS:
                    RestRequestUtils.setTestStepConfiguration(data, testCase, previousExpectedResponse, previousActualResponse)
                    break
					
                case "JDBC":
                    JDBCRequestUtils.setTestStepConfiguration(data, testCase, previousExpectedResponse, previousActualResponse)
                    break
				
				case "FIND":
				    FindRequestUtils.processFind(data, testCase, previousExpectedResponse, previousActualResponse)
				    break
				
                case "PAUSE":
                    testRunner.getTestCase().getTestStepByName(method).setPropertyValue("ExpectedResult", resourcePath)
                    break
					
				case "WAIT":
				    DelayUtils.setTestStepConfiguration(data, testCase)
					break
            }

            // Resolve references to properties from config file and from SoapUI project in test data
            TestData.substitutePropertiesInResponse(data, properties)
            TestData.substituteVariablesInResponse(data, evalUtils.VARIABLES)
			TestData.substituteVariablesInResponse(data, evalUtils.PRODUCT_VARIABLES)

            def expectedResponse = getExpectedResponseFromData(data, previousActualResponse, previousExpectedResponse)
            testCase.setPropertyValue(EXPECTED_RESPONSE_PROPERTY, expectedResponse)

            log.info "expectedResponse.evalScript = ${data.expectedResponse.evalScript}"
            testCase.setPropertyValue(EVALUATE_RESPONSE_SCRIPT_PROPERTY, data.expectedResponse.evalScript)

			def testName = "[TC_${testCase.name}]"
		
			def namingPattern = properties?.getProperty(TEST_CASE_NAMING_PATTERN_PROPERTY)
			if ( namingPattern != null )
			  testName = findTestCaseName (data.description,namingPattern,testCase.name)
			
            // Log description for this iteration
            def description = "${testName} Step: ${data.description}  @: ${method} ${resourcePath}".trim()
            testCase.setPropertyValue(DESCRIPTION_PROPERTY, description);
            log.info description
			
			// NOTE: data.method can be reassigned to point to test step template requests that should be executed in reality
			//       so data.method is used to choose next step for execution, variable 'method' is used for logging purposes
            if ( data.method == "SKIP") {
                log.info "Test Step Skipped"
                testRunner.gotoStepByName("Looper")
            } else if (testCase.getTestStepByName(data.method))
                testRunner.gotoStepByName(data.method)
            else {
                log.error "Test Step ${data.method} (named in DATA file as ${method}) does not exist"
                testRunner.gotoStepByName("Looper")
            }

        } 
	
		else {
            testCase.setPropertyValue(CURRENT_ROW_PROPERTY, testData.countRows.toString())
            testRunner.gotoStepByName("Looper")
        }

		
    }