Test Cases

This chapter focuses on services for the test cases.

Get all test cases

A GET to /test-cases returns all the test-cases that the client is allowed to read.

HTTP request

GET /api/rest/latest/test-cases?page=1&size=2 HTTP/1.1
Accept: application/json
Host: localhost:8080

Request parameters

Parameter Description

page

number of the page to retrieve (optional)

size

size of the page to retrieve (optional)

sort

which attributes of the returned entities should be sorted on (optional)

fields

which fields of the elements should be returned (optional)

HTTP response

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 1232

{
  "_embedded" : {
    "test-cases" : [ {
      "_type" : "test-case",
      "id" : 1,
      "name" : "sample standard test case",
      "reference" : "TC1",
      "kind" : "STANDARD",
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/api/rest/latest/test-cases/1"
        }
      }
    }, {
      "_type" : "test-case",
      "id" : 2,
      "name" : "sample script test case",
      "reference" : "TC2",
      "kind" : "GHERKIN",
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/api/rest/latest/test-cases/2"
        }
      }
    } ]
  },
  "_links" : {
    "first" : {
      "href" : "http://localhost:8080/api/rest/latest/test-cases?page=0&size=2"
    },
    "prev" : {
      "href" : "http://localhost:8080/api/rest/latest/test-cases?page=0&size=2"
    },
    "self" : {
      "href" : "http://localhost:8080/api/rest/latest/test-cases?page=1&size=2"
    },
    "next" : {
      "href" : "http://localhost:8080/api/rest/latest/test-cases?page=2&size=2"
    },
    "last" : {
      "href" : "http://localhost:8080/api/rest/latest/test-cases?page=2&size=2"
    }
  },
  "page" : {
    "size" : 2,
    "totalElements" : 5,
    "totalPages" : 3,
    "number" : 1
  }
}

Response fields

Path Type Description

_embedded.test-cases

Array

the list of elements for that page

page.size

Number

the page size for that query

page.totalElements

Number

total number of elements the client is allowed to read

page.totalPages

Number

how many pages can be browsed

page.number

Number

the page number

_links

Object

related links

Relation Description

first

link to the first page (optional)

prev

link to the previous page (optional)

self

link to this page

next

link to the next page (optional)

last

link to the last page (optional)

Create test case

A POST to /test-cases creates a new test case.

HTTP request

POST /api/rest/latest/test-cases HTTP/1.1
Content-Type: application/json
Accept: application/json
Host: localhost:8080
Content-Length: 129

{
  "_type" : "test-case",
  "name" : "Christmas turkey test flight",
  "parent" : {
    "_type" : "project",
    "id" : 15
  }
}

HTTP response

HTTP/1.1 201 Created
Content-Type: application/json;charset=UTF-8
Content-Length: 1782

{
  "_type" : "test-case",
  "id" : 240,
  "name" : "Christmas turkey test flight",
  "reference" : "",
  "kind" : "STANDARD",
  "project" : {
    "_type" : "project",
    "id" : 15,
    "name" : "Christmas Eve",
    "_links" : {
      "self" : {
        "href" : "http://localhost:8080/api/rest/latest/projects/15"
      }
    }
  },
  "path" : "/Christmas Eve/Christmas turkey test flight",
  "parent" : {
    "_type" : "project",
    "id" : 15,
    "name" : "Christmas Eve",
    "_links" : {
      "self" : {
        "href" : "http://localhost:8080/api/rest/latest/projects/15"
      }
    }
  },
  "created_by" : "admin",
  "created_on" : "2017-06-15T10:00:00.000+0000",
  "last_modified_by" : "admin",
  "last_modified_on" : "2017-06-15T10:00:00.000+0000",
  "importance" : "LOW",
  "status" : "WORK_IN_PROGRESS",
  "nature" : {
    "code" : "NAT_FUNCTIONAL_TESTING"
  },
  "type" : {
    "code" : "TYP_EVOLUTION_TESTING"
  },
  "prerequisite" : "",
  "description" : null,
  "custom_fields" : [ ],
  "steps" : [ ],
  "parameters" : [ ],
  "datasets" : [ ],
  "language" : "",
  "script" : "",
  "verified_requirements" : [ ],
  "attachments" : [ ],
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/api/rest/latest/test-cases/240"
    },
    "project" : {
      "href" : "http://localhost:8080/api/rest/latest/projects/15"
    },
    "steps" : {
      "href" : "http://localhost:8080/api/rest/latest/test-cases/240/steps"
    },
    "parameters" : {
      "href" : "http://localhost:8080/api/rest/latest/test-cases/240/parameters"
    },
    "datasets" : {
      "href" : "http://localhost:8080/api/rest/latest/test-cases/240/datasets"
    },
    "attachments" : {
      "href" : "http://localhost:8080/api/rest/latest/test-cases/240/attachments"
    }
  }
}

Get test case

A GET to /test-cases/{id} returns the test case with the given id.

Path parameters

Table 1. /api/rest/latest/test-cases/{id}
Parameter Description

id

the id of the test case

HTTP request

GET /api/rest/latest/test-cases/238 HTTP/1.1
Accept: application/json
Host: localhost:8080

Request parameters

Parameter Description

fields

which fields of the elements should be returned (optional)

HTTP response

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 5462

{
  "_type" : "test-case",
  "id" : 238,
  "name" : "walking test",
  "reference" : "TC1",
  "kind" : "STANDARD",
  "project" : {
    "_type" : "project",
    "id" : 14,
    "name" : "sample project",
    "_links" : {
      "self" : {
        "href" : "http://localhost:8080/api/rest/latest/projects/14"
      }
    }
  },
  "path" : "/sample project/sample folder/walking test",
  "parent" : {
    "_type" : "test-case-folder",
    "id" : 237,
    "name" : "sample folder",
    "_links" : {
      "self" : {
        "href" : "http://localhost:8080/api/rest/latest/test-case-folders/237"
      }
    }
  },
  "created_by" : "User-1",
  "created_on" : "2017-06-15T10:00:00.000+0000",
  "last_modified_by" : "User-1",
  "last_modified_on" : "2017-06-15T10:00:00.000+0000",
  "importance" : "LOW",
  "status" : "WORK_IN_PROGRESS",
  "nature" : {
    "code" : "NAT_USER_TESTING"
  },
  "type" : {
    "code" : "TYP_EVOLUTION_TESTING"
  },
  "prerequisite" : "<p>You must have legs with feet attached to them (one per leg)</p>\n",
  "description" : "<p>check that you can walk through the API (literally)</p>\n",
  "custom_fields" : [ {
    "code" : "CF_TXT",
    "label" : "test level",
    "value" : "mandatory"
  }, {
    "code" : "CF_TAGS",
    "label" : "see also",
    "value" : [ "walking", "bipedal" ]
  } ],
  "steps" : [ {
    "_type" : "action-step",
    "id" : 165,
    "action" : "<p>move ${first_foot} forward</p>\n",
    "expected_result" : "<p>I just advanced by one step</p>\n",
    "index" : 0,
    "custom_fields" : [ {
      "code" : "CF_TXT",
      "label" : "test level",
      "value" : "mandatory"
    }, {
      "code" : "CF_TAGS",
      "label" : "see also",
      "value" : [ "basic", "walking" ]
    } ],
    "attachments" : [ ],
    "_links" : {
      "self" : {
        "href" : "http://localhost:8080/api/rest/latest/test-steps/165"
      }
    }
  }, {
    "_type" : "action-step",
    "id" : 166,
    "action" : "<p>move ${second_foot}&nbsp;forward</p>\n",
    "expected_result" : "<p>and another step !</p>\n",
    "index" : 1,
    "custom_fields" : [ {
      "code" : "CF_TXT",
      "label" : "test level",
      "value" : "mandatory"
    }, {
      "code" : "CF_TAGS",
      "label" : "see also",
      "value" : [ "basic", "walking" ]
    } ],
    "attachments" : [ ],
    "_links" : {
      "self" : {
        "href" : "http://localhost:8080/api/rest/latest/test-steps/166"
      }
    }
  }, {
    "_type" : "call-step",
    "id" : 167,
    "delegate_parameter_values" : false,
    "called_test_case" : {
      "_type" : "test-case",
      "id" : 239,
      "name" : "victory dance",
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/api/rest/latest/test-cases/239"
        }
      }
    },
    "called_dataset" : null,
    "index" : 2,
    "_links" : {
      "self" : {
        "href" : "http://localhost:8080/api/rest/latest/test-steps/167"
      }
    }
  }, {
    "_type" : "call-step",
    "id" : 168,
    "delegate_parameter_values" : false,
    "called_test_case" : {
      "_type" : "unauthorized-resource",
      "resource_type" : "test-case",
      "resource_id" : 240,
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/api/rest/latest/test-cases/240"
        }
      }
    },
    "called_dataset" : null,
    "index" : 3,
    "_links" : {
      "self" : {
        "href" : "http://localhost:8080/api/rest/latest/test-steps/168"
      }
    }
  } ],
  "parameters" : [ {
    "_type" : "parameter",
    "id" : 1,
    "name" : "first_foot",
    "_links" : {
      "self" : {
        "href" : "http://localhost:8080/api/rest/latest/parameters/1"
      }
    }
  }, {
    "_type" : "parameter",
    "id" : 2,
    "name" : "second_foot",
    "_links" : {
      "self" : {
        "href" : "http://localhost:8080/api/rest/latest/parameters/2"
      }
    }
  } ],
  "datasets" : [ {
    "_type" : "dataset",
    "id" : 1,
    "name" : "right handed people",
    "_links" : {
      "self" : {
        "href" : "http://localhost:8080/api/rest/latest/datasets/1"
      }
    }
  }, {
    "_type" : "dataset",
    "id" : 2,
    "name" : "left handed people",
    "_links" : {
      "self" : {
        "href" : "http://localhost:8080/api/rest/latest/datasets/2"
      }
    }
  } ],
  "language" : "",
  "script" : "",
  "verified_requirements" : [ {
    "_type" : "requirement-version",
    "id" : 255,
    "name" : "Must have legs",
    "_links" : {
      "self" : {
        "href" : "http://localhost:8080/api/rest/latest/requirement-versions/255"
      }
    }
  }, {
    "_type" : "unauthorized-resource",
    "resource_type" : "requirement-version",
    "resource_id" : 256,
    "_links" : {
      "self" : {
        "href" : "http://localhost:8080/api/rest/latest/requirement-versions/256"
      }
    }
  } ],
  "attachments" : [ ],
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/api/rest/latest/test-cases/238"
    },
    "project" : {
      "href" : "http://localhost:8080/api/rest/latest/projects/14"
    },
    "steps" : {
      "href" : "http://localhost:8080/api/rest/latest/test-cases/238/steps"
    },
    "parameters" : {
      "href" : "http://localhost:8080/api/rest/latest/test-cases/238/parameters"
    },
    "datasets" : {
      "href" : "http://localhost:8080/api/rest/latest/test-cases/238/datasets"
    },
    "attachments" : {
      "href" : "http://localhost:8080/api/rest/latest/test-cases/238/attachments"
    }
  }
}

Response fields

Path Type Description

id

Number

the id of the entity

_type

String

the type of the entity

name

String

name of the test case

kind

String

kind of the test case: standard or Gherkin

project

Object

project of the test case

parent

Object

the location of the test case (either a folder or the project if located at the root of the library)

path

String

the path of the test case

created_by

String

user that created the test case

created_on

String

timestamp of the creation (ISO 8601)

last_modified_by

String

user that modified the test case the most recently

last_modified_on

String

timestamp of last modification (ISO 8601)

reference

String

a shorter identifier for that test case

importance

String

code of the importance

status

String

code of the status

nature.code

String

code of the nature

type.code

String

code of the type of test case

description

String

description of the test case (html)

prerequisite

String

prerequisites that should be met before the execution of the test script (html)

custom_fields

Array

array of custom fields

custom_fields[].code

String

code of the custom field

custom_fields[].label

String

label of the custom field

custom_fields[].value

Varies

the value of the custom field. The value is either a string (for most custom fields), or an array of strings (for multivalued custom fields eg a tag list)

steps

Array

the step list that constitute the script. Please refer to the test steps documentation.

parameters

Array

the list of parameters. Please refer to the parameters documentation.

datasets

Array

the list of datasets. Please refer to the datasets documentation.

language

String

the language used for script test case.

script

String

the script of Gherkin test case.

verified_requirements

Array

the list of verified requirements. Please refer to the requirements documentation.

attachments

Array

the list of attachments.

_links

Object

related links

Relation Description

self

link to this test case

project

link to its project

steps

link to the test script

parameters

link to the parameters

datasets

link to the datasets

attachments

link to the attachments

Modify test case

A PATCH to /test-cases/{id} modifies the test case with the given id.

HTTP request

PATCH /api/rest/latest/test-cases/240 HTTP/1.1
Content-Type: application/json
Accept: application/json
Host: localhost:8080
Content-Length: 70

{
  "_type" : "test-case",
  "name" : "Christmas turkey test launch"
}

HTTP response

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 1782

{
  "_type" : "test-case",
  "id" : 240,
  "name" : "Christmas turkey test launch",
  "reference" : "",
  "kind" : "STANDARD",
  "project" : {
    "_type" : "project",
    "id" : 15,
    "name" : "Christmas Eve",
    "_links" : {
      "self" : {
        "href" : "http://localhost:8080/api/rest/latest/projects/15"
      }
    }
  },
  "path" : "/Christmas Eve/Christmas turkey test launch",
  "parent" : {
    "_type" : "project",
    "id" : 15,
    "name" : "Christmas Eve",
    "_links" : {
      "self" : {
        "href" : "http://localhost:8080/api/rest/latest/projects/15"
      }
    }
  },
  "created_by" : "admin",
  "created_on" : "2017-06-15T10:00:00.000+0000",
  "last_modified_by" : "admin",
  "last_modified_on" : "2017-06-15T10:00:00.000+0000",
  "importance" : "LOW",
  "status" : "WORK_IN_PROGRESS",
  "nature" : {
    "code" : "NAT_FUNCTIONAL_TESTING"
  },
  "type" : {
    "code" : "TYP_EVOLUTION_TESTING"
  },
  "prerequisite" : "",
  "description" : null,
  "custom_fields" : [ ],
  "steps" : [ ],
  "parameters" : [ ],
  "datasets" : [ ],
  "language" : "",
  "script" : "",
  "verified_requirements" : [ ],
  "attachments" : [ ],
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/api/rest/latest/test-cases/240"
    },
    "project" : {
      "href" : "http://localhost:8080/api/rest/latest/projects/15"
    },
    "steps" : {
      "href" : "http://localhost:8080/api/rest/latest/test-cases/240/steps"
    },
    "parameters" : {
      "href" : "http://localhost:8080/api/rest/latest/test-cases/240/parameters"
    },
    "datasets" : {
      "href" : "http://localhost:8080/api/rest/latest/test-cases/240/datasets"
    },
    "attachments" : {
      "href" : "http://localhost:8080/api/rest/latest/test-cases/240/attachments"
    }
  }
}

Get datasets of test case

A GET to /test-cases/{id}/datasets returns all the datasets of the test case with the given id.

Path parameters

Table 1. /api/rest/latest/test-cases/{id}/datasets
Parameter Description

id

the id of the test case

HTTP request

GET /api/rest/latest/test-cases/238/datasets HTTP/1.1
Accept: application/json
Host: localhost:8080

Request parameters

Parameter Description

page

number of the page to retrieve (optional)

size

size of the page to retrieve (optional)

fields

which fields of the elements should be returned (optional)

HTTP response

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 1804

{
  "_embedded" : {
    "datasets" : [ {
      "_type" : "dataset",
      "id" : 1,
      "name" : "big_cake",
      "parameters" : [ {
        "_type" : "parameter",
        "id" : 1,
        "name" : "cocoa_purity"
      }, {
        "_type" : "parameter",
        "id" : 2,
        "name" : "number_of_layers"
      } ],
      "parameter_values" : [ {
        "parameter_test_case_id" : 238,
        "parameter_value" : "98%",
        "parameter_name" : "cocoa_purity",
        "parameter_id" : 1
      }, {
        "parameter_test_case_id" : 238,
        "parameter_value" : "4",
        "parameter_name" : "number_of_layers",
        "parameter_id" : 2
      } ],
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/api/rest/latest/datasets/1"
        }
      }
    }, {
      "_type" : "dataset",
      "id" : 2,
      "name" : "biscuit",
      "parameters" : [ {
        "_type" : "parameter",
        "id" : 1,
        "name" : "cocoa_purity"
      }, {
        "_type" : "parameter",
        "id" : 2,
        "name" : "number_of_layers"
      } ],
      "parameter_values" : [ {
        "parameter_test_case_id" : 238,
        "parameter_value" : "80%",
        "parameter_name" : "cocoa_purity",
        "parameter_id" : 1
      }, {
        "parameter_test_case_id" : 238,
        "parameter_value" : "1",
        "parameter_name" : "number_of_layers",
        "parameter_id" : 2
      } ],
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/api/rest/latest/datasets/2"
        }
      }
    } ]
  },
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/api/rest/latest/test-cases/238/datasets?page=0&size=20"
    }
  },
  "page" : {
    "size" : 20,
    "totalElements" : 2,
    "totalPages" : 1,
    "number" : 0
  }
}

Response fields

Path Type Description

_embedded.datasets

Array

the datasets of this test case

page.size

Number

the page size for that query

page.totalElements

Number

total number of elements the client is allowed to read

page.totalPages

Number

how many pages can be browsed

page.number

Number

the page number

_links

Object

related links

Relation Description

first

link to the first page (optional)

prev

link to the previous page (optional)

self

link to this page

next

link to the next page (optional)

last

link to the last page (optional)

Get parameters of test case

A GET to /test-cases/{id}/parameters returns all the parameters of the test case with the given id.

Path parameters

Table 1. /api/rest/latest/test-cases/{id}/parameters
Parameter Description

id

the id of the test case

HTTP request

GET /api/rest/latest/test-cases/238/parameters HTTP/1.1
Accept: application/json
Host: localhost:8080

Request parameters

Parameter Description

page

number of the page to retrieve (optional)

size

size of the page to retrieve (optional)

fields

which fields of the elements should be returned (optional)

HTTP response

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 1380

{
  "_embedded" : {
    "parameters" : [ {
      "_type" : "parameter",
      "id" : 1,
      "name" : "cocoa_purity",
      "description" : "<p>how refined the cocoa cream should be</p>",
      "test_case" : {
        "_type" : "test-case",
        "id" : 238,
        "name" : "Chocolate cake",
        "_links" : {
          "self" : {
            "href" : "http://localhost:8080/api/rest/latest/test-cases/238"
          }
        }
      },
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/api/rest/latest/parameters/1"
        }
      }
    }, {
      "_type" : "parameter",
      "id" : 2,
      "name" : "number_of_layers",
      "description" : "<p>how many times should the base pattern be repeated</p>",
      "test_case" : {
        "_type" : "test-case",
        "id" : 238,
        "name" : "Chocolate cake",
        "_links" : {
          "self" : {
            "href" : "http://localhost:8080/api/rest/latest/test-cases/238"
          }
        }
      },
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/api/rest/latest/parameters/2"
        }
      }
    } ]
  },
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/api/rest/latest/test-cases/238/parameters?page=0&size=20"
    }
  },
  "page" : {
    "size" : 20,
    "totalElements" : 2,
    "totalPages" : 1,
    "number" : 0
  }
}

Response fields

Path Type Description

_embedded.parameters

Array

the parameters of this test case

page.size

Number

the page size for that query

page.totalElements

Number

total number of elements the client is allowed to read

page.totalPages

Number

how many pages can be browsed

page.number

Number

the page number

_links

Object

related links

Relation Description

first

link to the first page (optional)

prev

link to the previous page (optional)

self

link to this page

next

link to the next page (optional)

last

link to the last page (optional)

Get steps of test case

A GET to /test-cases/{id}/test-steps returns all the steps of the test case with the given id.

Path parameters

Table 1. /api/rest/latest/test-cases/{id}/steps
Parameter Description

id

the id of the test case

HTTP request

GET /api/rest/latest/test-cases/239/steps HTTP/1.1
Accept: application/json
Host: localhost:8080

Request parameters

Parameter Description

page

number of the page to retrieve (optional)

size

size of the page to retrieve (optional)

fields

which fields of the elements should be returned (optional)

HTTP response

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Content-Length: 2399

{
  "_embedded" : {
    "steps" : [ {
      "_type" : "action-step",
      "id" : 167,
      "action" : "<p>Quick step forward</p>\n",
      "expected_result" : "<p>So does your opponent</p>\n",
      "index" : 0,
      "custom_fields" : [ {
        "code" : "CHK_BODY_FEINT",
        "label" : "requires body feint",
        "value" : "false"
      } ],
      "attachments" : [ ],
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/api/rest/latest/test-steps/167"
        }
      }
    }, {
      "_type" : "action-step",
      "id" : 168,
      "action" : "<p>Another quick step forward, albeit smaller</p>\n",
      "expected_result" : "<p>Opponent&nbsp;doubles his steps too then lunges forward for an attack</p>\n",
      "index" : 1,
      "custom_fields" : [ {
        "code" : "CHK_BODY_FEINT",
        "label" : "requires body feint",
        "value" : "true"
      } ],
      "attachments" : [ ],
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/api/rest/latest/test-steps/168"
        }
      }
    }, {
      "_type" : "action-step",
      "id" : 169,
      "action" : "<p>Strong Quarte parry, possibly with a slight retreat.</p>\n",
      "expected_result" : "<p>Opponent&#39;s attack gets blocked by your blade.</p>\n",
      "index" : 2,
      "custom_fields" : [ {
        "code" : "CHK_BODY_FEINT",
        "label" : "requires body feint",
        "value" : "false"
      } ],
      "attachments" : [ ],
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/api/rest/latest/test-steps/169"
        }
      }
    }, {
      "_type" : "call-step",
      "id" : 170,
      "delegate_parameter_values" : true,
      "called_test_case" : {
        "_type" : "test-case",
        "id" : 240,
        "name" : "Compound riposte",
        "_links" : {
          "self" : {
            "href" : "http://localhost:8080/api/rest/latest/test-cases/240"
          }
        }
      },
      "called_dataset" : null,
      "index" : 3,
      "_links" : {
        "self" : {
          "href" : "http://localhost:8080/api/rest/latest/test-steps/170"
        }
      }
    } ]
  },
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/api/rest/latest/test-cases/239/steps?page=0&size=20"
    }
  },
  "page" : {
    "size" : 20,
    "totalElements" : 4,
    "totalPages" : 1,
    "number" : 0
  }
}

Response fields

Path Type Description

_embedded.steps

Array

the steps of this test case

page.size

Number

the page size for that query

page.totalElements

Number

total number of elements the client is allowed to read

page.totalPages

Number

how many pages can be browsed

page.number

Number

the page number

_links

Object

related links

Relation Description

first

link to the first page (optional)

prev

link to the previous page (optional)

self

link to this page

next

link to the next page (optional)

last

link to the last page (optional)