DevMate method chaining allows you to

  • Include more than one method in a single scenario.

  • Pass the output from one method to the next method.

  • You cannot pass method output between scenarios, however.


You can find the code relating to this tutorial on Github in the /java/util/chaining folder.


Here’s our method to be tested.

  • It requires an input >= 1 otherwise it throws an Exception.

  • It returns input * 10.

We are going to use chaining to call this method and then DevMate will call the same method again.

This example is very basic but the principle can be applied to objects as well as primitives.

  • First, right-click the multiplyPositiveByTen method and choose Test with DevMate. Save the file. It will automatically open up the DevMate editor.

Configuring the first method call

You should now be comfortable defining equivalence classes, so go ahead and configure the 4 values we need to use for our test cases.

Adding the second method call

We can now add the second call to our multiplyPositiveByTen() method.

  1. Click on the Classes/Methods tab on the left.

  2. Enter a part of the method name to save scrolling.

  3. Right click the method.

  4. Select Add method to active scenario.

Configuring the second method

You will now see our second method added. Note, we’ve collapses the first method here so we can see things more clearly.

  1. Collapse the first method we added earlier.

  2. Click on the hamburger icon.

  3. Click on the last item to add the output data from the previous method

You will then see a default value appear. It might show a dropdown immediately or you might see a default value.

  • Double click this representative value to reveal a dropdown. If the dropdown is already shown, then click and select M1, which is the previous method. It should now be set to Return value of M1.

  • Complete the reset of the second method’s inputs as shown below.

  1. As done above.

  2. We can expect 300 as the first method should return 30.

  3. We’ve added an exception here, but it shouldn’t matter what you put as the first method failed anyway.

Generate test cases

Now we’re ready to generate the test cases.

  • Press the Generate Test Cases button and complete everything for both methods.

Here’s the first method.

And this is the second.

Generate test code and run test

You can now press the Generate Test Code button and your test code is generated.

Open up the test and run it. It should pass first time.