Join 34,000+ subscribers and receive articles from our blog about software quality, testing, QA and security.
 

Need help with Separated Steps and Separated Expected Results


#1

[code]
function custom_filter($csv)
{
// Skip the first line
unset($csv[0]);

// Iterate rows and build cases
foreach ($csv as $row)
{
    // Create a new case and assign the various properties
    $case = array();
    $case['title'] = $row[0];
    $case['type'] = $row[1];
    $case['priority'] = $row[2];

    // Custom fields, such as Preconditions, Steps and
    // Expected Results
    $custom = array();
    $custom['preconds'] = $row[3];
    $custom['steps_separated'] = 
        array('collection:step' => 
            array(
                array('index' => 1, 'content' => $row[4], 'expected' => $row[5])                    
            )
        );
    
    $case['custom'] = $custom;

    // The export script will automatically create the section
    // hierarchy for us. All we have to do is to specify the
    // sections for a test case in this format:
    //
    // "Section 1 > Section 2 > Section 3"
    $case['section'] = $row[6];
    $case['testsuite'] = $row[7];
    // Add the cases to the list
    $cases[] = $case;
}

// Return all cases
return $cases;

}[/code]

Steps 1 and 2 are in one cell and Expected Results 1 and 2 are in one cell in the CSV file.


#2

Hello,

Thanks for your posting and my apologies for the delayed response. You would need to split the step/expected result columns into multiple parts as part of the conversion script. You are currently only adding one single step.

The idea would be to split the steps/expected result value into multiple items (for example, split by empty line) and then add those steps to $custom[‘steps_separated’]. The “advanced” example that is part of the migration tool demonstrates how to add the steps/expected results dynamically. We are also happy to help in case you have any further questions.

Regards,
Tobias