Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time


The following code is an example of one test that was automatically generated by EvoMaster for a REST service called "scout-api" (see EMB repository). The generated test uses the RestAssured library.

public void test_36_with500() throws Exception {
   String location_media_files = "";
   String id_0 = given().accept("application/json")
                .header("Authorization", "ApiKey moderator") // moderator
                .body(" { " + 
                    " \"uri\": \"hXf3e8B3ikGtuGjT\", " + 
                    " \"name\": \"nkeUfXVTC\", " + 
                    " \"copy_right\": \"\" " + 
                    " } ")
                .post(baseUrlOfSut + "/api/v1/media_files")
                .body("'uri'", containsString("hXf3e8B3ikGtuGjT"))
                .body("'name'", containsString("nkeUfXVTC"))
                .body("'copy_right'", containsString(""))
   location_media_files = "/api/v1/media_files/" + id_0;
                .header("Authorization", "ApiKey moderator") // moderator
                .get(resolveLocation(location_media_files, baseUrlOfSut + "/api/v1/media_files/1579038228/file"))
                .statusCode(500) // se/devscout/scoutapi/resource/MediaFileResource_268_downloadFile
                .body("'code'", numberMatches(500.0));

In this automatically generated test, a new resource is first created with a POST command. The id of this newly generated resource is then extracted from the POST response, and used in the URL of a following GET request on a sub-resource. Such GET request does break the backend, as it returns a 500 HTTP status code. The last line executed in the business logic of the backend is then printed as comment, to help debugging this fault.

The generated tests are self-contained, i.e., they start/stop the REST server by themselves:

    private static SutHandler controller = new;
    private static String baseUrlOfSut;
    public static void initClass() {
        baseUrlOfSut = controller.startSut();
        RestAssured.urlEncodingEnabled = false;
    public static void tearDown() {
    public void initTest() {

The ability of starting/resetting/stopping the tested application is critical for using the generated tests in Continuous Integration (e.g., Jenkins, Travis and CircleCI). However, it requires to write a driver to tell EvoMaster how to do such start/reset/stop.

A generated test is not only going to be a sequence of HTTP calls toward a running application. EvoMaster can also set up the environment of the application, like automatically adding all the needed data into a SQL database.