Generics
This is a simple tutorial to show how DevMate works with generics
Github
You can find the code relating to this tutorial on Github in the /java/util/generics
folder.
The method
Here is the simplest method we could come up with. Let us know if we can make it simpler!

Right click on the
isEqual()
method name to generate a test with DevMate.
Configuring <T>
We’ll start out by instantiating GenereicDemo
(we didn't use a static class this time).

Create a valid representative (click the + icon and select
GenericDemo
from the initializer dropdown).Make sure you click on the method cell as shown.
Click the Properties button to open up the panel on the right (the properties won’t appear until you do).
You can see the Types dropdown. Choose a type from the dropdown - why not choose an
int
type? You’ll notice that the<T>
has now been replaced by <int>. You can close the properties panel now if you like.
Configuring inputs and outputs
Let’s set up some a simple valid and invalid test.

Let’s create a valid equivalence class value of
100
forg1.
And
100
forg2
(they need to be the same as it's testing equality.We’ll create an invalid equivalence class with value
101
(so equality fails).The valid output equivalence class return
true
And the invalid,
false
.
And with that, you can press Generate Test Code and run your test.