Example #1
0
func (e *specExecutor) executeTableDrivenSpec() {
	var dataTableScenarioExecutionResult [][]*result.ScenarioResult
	for e.currentTableRow = e.dataTableIndex.start; e.currentTableRow <= e.dataTableIndex.end; e.currentTableRow++ {
		var dataTable gauge.Table
		dataTable.AddHeaders(e.specification.DataTable.Table.Headers)
		dataTable.AddRowValues(e.specification.DataTable.Table.Rows()[e.currentTableRow])
		e.consoleReporter.DataTable(formatter.FormatTable(&dataTable))
		dataTableScenarioExecutionResult = append(dataTableScenarioExecutionResult, e.executeScenarios())
	}
	e.specResult.AddTableDrivenScenarioResult(dataTableScenarioExecutionResult)
}
Example #2
0
func convertCsvToTable(csvContents string) (*gauge.Table, error) {
	r := csv.NewReader(strings.NewReader(csvContents))
	r.Comment = '#'
	lines, err := r.ReadAll()
	if err != nil {
		return nil, err
	}
	table := new(gauge.Table)
	for i, line := range lines {
		if i == 0 {
			table.AddHeaders(line)
		} else {
			table.AddRowValues(line)
		}
	}
	return table, nil
}