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

Import test cases (xml) in to TestRail


#1

I just created one sample xml file to import test case into TestRail. But it created one more sections called All Test Cases. I thought my test case will be added under existing All Test Cases sections. But it created one more All Test Cases section. It happened for me another section too. (we have 2 section with same name).
we are using TestRail v4.0.3.3270 version.

Please help us.


#2

Hello Ramkumar,

Thanks for your posting! Importing test cases always creates new sections but you can simply rearrange your test cases by moving them via drag & drop:

You can either move them directly in the case list, or drop them to a section in the sidebar. You can start the drag via the icon left to the checkbox.

I hope this helps!

Regards,
Tobias


#3

Thanks for your reply. can’t we avoid this behaviour. we are planning to automate this task with jenkins. We cannot move test cases by manually. If we upgrade to latest TestRail version will it solve our problem.


#4

Hi Ramkumar,

Thanks for your reply. If you plan to use TestRail’s API, you wouldn’t usually the XML or CSV import but TestRail’s API methods instead. The methods are more flexible than the imports and you can specify the section you want to add your cases to (so, TestRail wouldn’t automatically add a second section).

The relevant API methods for adding sections and cases would be add_section and add_case:

http://docs.gurock.com/testrail-api2/reference-cases
http://docs.gurock.com/testrail-api2/reference-sections

Cheers,
Tobias


#5

Hi Tobias,

Thanks for your reply. I am able to add test cases through TestRail’s API method. But it is keep on creating test cases even if it exists. I thought it will return a error for existing test cases but it is not. As you said sections are not getting created(duplicated) because I mentioned section id in API method.

Import XML method also keep on creating(duplicating) the sections and test cases with different id.

Both methods are not helping us.

Regards,
Ramkumar


#6

Hello Ramkumar,

Thanks for your reply! TestRail wouldn’t prevent you from adding multiple test cases with the same title because this is a valid and often used scenario (especially across multiple sections but also in the same section). You can get a list of cases via get_cases and then add only those cases that are not in this list. I would recommend getting the list of cases first and then going through your cases you want to add one by one and comparing this to the (cached) list of existing cases.

Regards,
Tobias