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

Can't create custom test steps


#1

Hi,

I’m trying to create a test case automatically using the Testrail API.

But creating custom test steps fails all the time (using field type “Test Case (Steps)” )

The HTTP Request seems to work properly for me, the test case it created too, but there are simply no steps after creation.

This is my steps field declaration:

step_config

And this is the way I put my step data into the HTTP request:

    var stepData = HashMap<String,String>()

    stepData.put("content", "do something")
    stepData.put("expected", "expect something")

    data.put("steps_separated",stepData)

    sendPost(testrailURL + "index.php?/api/v2/add_case/" + sectionID, data)

On “http://docs.gurock.com/testrail-api2/reference-cases#get_case” is mentioned that a custom field has to be the prefix “custom_”. Could this be the reason?

If yes: Which workaround can I use to run my request successfully? It will be an important topic for test Automation in the future.

But I neither can’t change the field type, nor I can’t delete the existing field because there are already some projects containing lots of test cases using this field.

If no: What might be the Problem I miss?

Thanks and regards,
Achim


#2

Unfortunately, it doesn’t work this way too:

var stepData = ArrayList<HashMap<String, String>>()
var stepMap = HashMap<String,String>
stepMap.put("content", "do something")
stepMap.put("expected","expect something") 
stepData.add(stepMap)
data.put("custom_steps_separated",stepData)
sendPost(testrailURL + "index.php?/api/v2/add_case/" + sectionID, data

Post Arguments: {“refs”:“1,2,3”,“custom_steps_separated”:[{“expected”:“expect something”,“content”:“do something”}],“title”:“automatic generated test case”}

Response: {“id”:1764,“title”:“automatic generated test case”,“section_id”:425,“template_id”:1,“type_id”:7,“priority_id”:2,“milestone_id”:null,“refs”:“1,2,3”,“created_by”:1,“created_on”:1517837075,“updated_by”:1,“updated_on”:1517837075,“estimate”:null,“estimate_forecast”:null,“suite_id”:27,“custom_testfallstatus”:null,“custom_summary”:null,“custom_preconds”:null,“custom_steps”:null,“custom_steps_separated”:null,“custom_expected”:null,“custom_mission”:null,“custom_goals”:null}

As you can see the field ,“custom_steps_separated” is null. Why??? I don’t understand!

Can anybody help me, please? It blocks my work immensly!


#3

I found the reason for the problem.

Please consider the template_id attribute as mandatory-otherwise the separate steps will be discarded (without any error!!!) because the template is set to “Steps text”. The API documentation doesn’t mention this at the moment but I sended a request to change it.