File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
src/test/java/net/datafaker/providers/base Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -136,18 +136,21 @@ public InsectFaker(Locale locale) {
136136
137137 @ Test
138138 void weightedInsectNameTest () {
139+ int count = 300 ;
139140 MyCustomFaker myFaker = new MyCustomFaker ();
140141 Map <String , Integer > insectCounts = new HashMap <>();
141142 insectCounts .put ("Driver ant" , 0 );
142143 insectCounts .put ("Fire ant" , 0 );
143144 insectCounts .put ("Harvester ant" , 0 );
144145
145- for (int i = 0 ; i < 100 ; i ++) {
146+ for (int i = 0 ; i < count ; i ++) {
146147 String selectedInsect = myFaker .insect ().weightedInsectName ();
147148 insectCounts .put (selectedInsect , insectCounts .get (selectedInsect ) + 1 );
148149 }
149150
150- assertThat (insectCounts .get ("Driver ant" )).isGreaterThan (insectCounts .get ("Fire ant" ));
151- assertThat (insectCounts .get ("Fire ant" )).isGreaterThan (insectCounts .get ("Harvester ant" ));
151+ assertThat (insectCounts .keySet ()).containsExactlyInAnyOrder ("Driver ant" , "Fire ant" , "Harvester ant" );
152+ assertThat (insectCounts .values ().stream ().mapToInt (f -> f ).sum ()).as (() -> "Insects: " + insectCounts ).isEqualTo (count );
153+ assertThat (insectCounts .get ("Driver ant" )).as (() -> "Insects: " + insectCounts ).isGreaterThan (insectCounts .get ("Fire ant" ));
154+ assertThat (insectCounts .get ("Fire ant" )).as (() -> "Insects: " + insectCounts ).isGreaterThan (insectCounts .get ("Harvester ant" ));
152155 }
153156}
You can’t perform that action at this time.
0 commit comments