Skip to content

Commit ffc05d6

Browse files
Moar documentations on parameterized
1 parent f84a736 commit ffc05d6

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

Diff for: AndroidListenerExamples/src/androidTest/java/com/designatednerd/androidlistenerexamples/test/ParameterTestExample.java

+33-7
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,26 @@
1414
/**
1515
* Created by ellen on 5/19/15.
1616
*/
17+
//Needs RunWith annotation since it's using a more specific runner.
1718
@RunWith(Parameterized.class)
1819
public class ParameterTestExample {
1920

21+
/*******************
22+
* PARAMETER SETUP *
23+
*******************/
24+
25+
/**
26+
* Create an iterable of object arrays that can be handed over to the test
27+
* as parameters to the constructor.
28+
*
29+
* For example, here we have a constructor that takes 3 items: The first string,
30+
* the second string, and the expected overlap string. Each of these arrays
31+
* of strings will be passed in to the constructor in that order.
32+
*/
2033
@Parameters
2134
public static Iterable<Object[]> data() {
2235
return Arrays.asList(new Object[][] {
23-
{ "cat", "rat", "at" }, //Returns in order
36+
{ "cat", "eta", "at" }, //Returns in order of first string
2437
{ "dog", "pug", "g"}, //Single letter
2538
{ "bob", "steve", null }, //No letters
2639
{ "mary", "roger", "r"}, //Many of one letter
@@ -30,24 +43,37 @@ public static Iterable<Object[]> data() {
3043
});
3144
}
3245

33-
/**
34-
* Create your object and the things you're passing it.
35-
*/
46+
47+
/*************
48+
* VARIABLES *
49+
*************/
50+
3651
private String mFirstString;
3752
private String mSecondString;
3853
private String mExpectedCommonLetters;
3954
private CommonLetterFinder mLetterFinder;
4055

56+
/***************
57+
* CONSTRUCTOR *
58+
***************/
59+
60+
/**
61+
* Test constructor that takes the params defined above.
62+
* @param aFirstString The first string to compare.
63+
* @param aSecondString The second string to compare.
64+
* @param aCommonLetters The expected common letters in the string.
65+
*/
4166
public ParameterTestExample(String aFirstString, String aSecondString, String aCommonLetters) {
4267
mFirstString = aFirstString;
4368
mSecondString = aSecondString;
4469
mExpectedCommonLetters = aCommonLetters;
4570
mLetterFinder = new CommonLetterFinder();
4671
}
4772

48-
/**
49-
* Since this is being run with Parameterized, it will be run the number of times
50-
*/
73+
/***********************
74+
* PARAMETERIZED TESTS *
75+
***********************/
76+
5177
@Test
5278
public void findCommonLetters() {
5379
String foundCommonLetters = mLetterFinder.commonLetters(mFirstString, mSecondString);

0 commit comments

Comments
 (0)