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
Here’s our method to be tested.
It requires an
input >= 1otherwise it throws an
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
multiplyPositiveByTenmethod 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
Click on the Classes/Methods tab on the left.
Enter a part of the method name to save scrolling.
Right click the method.
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.
Collapse the first method we added earlier.
Click on the hamburger icon.
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.
As done above.
We can expect 300 as the first method should return 30.
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.