Skip to main content Skip to complementary content

Creating a test scenario

Create a scenario to add a movie and check the update in the catalog.

Procedure

  1. In Talend Cloud API Tester, open your API project in the SCENARIOS tab.
  2. Click Add a scenario at the bottom of the page.
    Add a scenario button in the interface.
  3. Give a name to your scenario Scenario 1, for example.
  4. Click the Three-dot menu button to the right of the Add a movie request and click Move.
    Interface to add requests to the scenario.
  5. In the Move Request window that opens, select Movie catalog API > Scenario 1 and click Move to save the request in your scenario.
  6. Repeat the previous steps to move the Get a list of movies request to your scenario.
  7. Click Edit scenario, then click Edit request in the Add a movie section.
  8. Enter a new movie in the BODY.

    Example

    <movie>
    	<movieId>7</movieId>
    	<title>First Man</title>
    	<releaseYear>2018</releaseYear>
    	<director>Damien Chazelle</director>
    	<price>5.99</price>
    </movie>
  9. In the ASSERTIONS section, click Add assertion and create the following assertion:
    Source Operator Expected value
    Status code Equals 200
  10. From the left panel, open the Get a list of movies request in your scenario.
  11. In the ASSERTIONS section, click Add assertion and configure the following assertions to check that the last entry in the database matches your previous POST request.
    Source Path selector Operator Expected value
    Status code Not applicable Equals 200
    XML Body //movies/movie[last()]/title Equals ${"Movie catalog API"."Scenario 1"."Add a movie"."request"."body".xPath("/movie/title")}

    To configure the expected value for the second assertion, you can click the magic wand icon next to the fourth field to create an expression and select Movie catalog API > Scenario 1 > Add a movie > request > body > movie > title.

    You can see the expression you created and a preview of its value.

    EXPRESSION BUILDER view.
  12. Click the play button to the left of your scenario in the left panel to run it.

Results

Talend Cloud API Tester sends the two requests in the order defined in the scenario. For the Get a list of movies request, you should get the following result:

Screenshot of the scenario running.

Once your tests are configured, you can automate them using the Talend Cloud API Tester Maven plugin. For more information, see Automating your API tests.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!