Tutorial: Generate test template
By analyzing function signatures and your custom types, Symflower can generate test templates that provide all the necessary boilerplate code for unit and integration testing. The only thing left for you is to fill out the expected values inside the test function.
Tutorial
To follow the feature tutorial below, start by copying the following code into a file named Copy.java
:
class Copy {
static String[] copy(String[] from, String[] to) {
for (int i = 0; i < from.length; i++) {
to[i] = from[i];
}
return to;
}
}
Use the sample Copy.java
code above and right-click anywhere in the function to open the context menu, then click "Symflower: Generate Test Template for Function". (Alternatively, use your defined hotkeys, the command palette, or the code lens to create the test template). The following new test template will be added to your test file:
@Test
public void copy() {
String[] from = { "abc", "abc", "abc" };
String[] to = { "abc", "abc", "abc" };
String[] expected = { "abc", "abc", "abc" };
String[] actual = Copy.copy(from, to);
assertArrayEquals(expected, actual);
}
Now all that is left for you to do is to properly name the method and replace the sample values with actual values.