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

Problem with import from excel


#1

Hello,

I did a customisation in testrail to have separated steps.
I’m trying to import my cases in testrail from excel (CSV).

The CSV file is with this structure (only test with one step in this file):
title;type;precondition;step1;expected;section

With my filter, I have my steps, but never the field “expected”.
Could you tell me what is the good syntax for this ?
Here is the last version of my filter

Thanks !!!

[code]<?php

/**

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];
    
    // Custom fields, such as Preconditions, Steps and
    // Expected Results
    $custom = array();
    $custom['preconds'] = trim($row[2]);
    $custom['steps_separated'] = 
        array('collection:step' => 
            array(
                array('index' => 1, 'content' => $row[3]),
            )
            $custom['expected'] = trim($row[4]);
        );    
    $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[5];

    // Add the cases to the list
    $cases[] = $case;
}

// Return all cases
return $cases;

}[/code]


#2

Hello again,

I fixed my problem with this discussion : http://forum.gurock.com/topic/830/migration-question/

The right filter is :

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

Thanks
:slight_smile:


#3

Thanks for your posting. Yes, the ‘expected’ should be directly part of the (collection:step) and it’s good to hear that you found the solution in the meantime. Please let me know in case you have any further questions.

Regards,
Tobias


#4

Tybaut - can you explain what this import accounts for in your own csv?

I want to create test cases that have step1,expected,step2,expected,step3,expected, (etc.)

Is that possible with what you’ve posted above?


#5

I believe you can do so by following the example in this response:

http://forum.gurock.com/post/3068/#p3068