How to use getInstance method of org.evomaster.client.java.instrumentation.example.methodreplacement.TestabilityExcInstrumentedTest class

Best EvoMaster code snippet using org.evomaster.client.java.instrumentation.example.methodreplacement.TestabilityExcInstrumentedTest.getInstance

Source:TestabilityExcInstrumentedTest.java Github

copy

Full Screen

...19/**20 * Created by arcuri82 on 27-Jun-19.21 */22public class TestabilityExcInstrumentedTest {23 protected TestabilityExc getInstance() throws Exception {24 InstrumentingClassLoader cl = new InstrumentingClassLoader("com.foo");25 return (TestabilityExc) cl.loadClass(TestabilityExcImp.class.getName()).newInstance();26 }27 @BeforeAll28 public static void initClass() {29 ObjectiveRecorder.reset(true);30 }31 @BeforeEach32 public void init() {33 ObjectiveRecorder.reset(false);34 ExecutionTracer.reset();35 assertEquals(0, ExecutionTracer.getNumberOfObjectives());36 }37 @Test38 public void testUnitsInfo() throws Exception{39 UnitsInfoRecorder.reset();40 UnitsInfoRecorder info = UnitsInfoRecorder.getInstance();41 assertEquals(0, info.getNumberOfUnits());42 assertEquals(0, info.getNumberOfReplacedMethodsInSut());43 TestabilityExc te = getInstance();44 info = UnitsInfoRecorder.getInstance();45 assertEquals(1, info.getNumberOfUnits());46 assertEquals(26, info.getNumberOfReplacedMethodsInSut());47 }48 @Test49 public void testParseIntValid() throws Exception {50 TestabilityExc te = getInstance();51 assertThrows(Exception.class, () -> te.parseInt(null));52 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));53 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));54 int value = te.parseInt("1");55 assertEquals(1, value);56 assertEquals(0, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));57 }58 @Test59 public void testParseIntHeuristic() throws Exception {60 TestabilityExc te = getInstance();61 assertThrows(Exception.class, () -> te.parseInt(null));62 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));63 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));64 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)65 .iterator().next();66 double h0 = ExecutionTracer.getValue(targetId);67 assertTrue(h0 > 0); //reached68 assertTrue(h0 < 1);//but no covered69 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));70 assertThrows(Exception.class, () -> te.parseInt("z"));71 double h1 = ExecutionTracer.getValue(targetId);72 assertTrue(h1 > h0); //better73 assertTrue(h1 < 1);//but still no covered74 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));75 assertThrows(Exception.class, () -> te.parseInt("a"));76 double h2 = ExecutionTracer.getValue(targetId);77 assertTrue(h2 > h1); //better78 assertTrue(h2 < 1);//but still no covered79 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));80 te.parseInt("1");81 double h3 = ExecutionTracer.getValue(targetId);82 assertTrue(h3 > h2); //better83 assertEquals(1, h3);//covered84 assertEquals(0, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));85 }86 @Test87 public void testParseLocalDateHeuristic() throws Exception {88 TestabilityExc te = getInstance();89 assertThrows(Exception.class, () -> te.parseLocalDate(null));90 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));91 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));92 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)93 .iterator().next();94 double h0 = ExecutionTracer.getValue(targetId);95 assertTrue(h0 > 0); //reached96 assertTrue(h0 < 1);//but no covered97 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));98 assertThrows(Exception.class, () -> te.parseLocalDate("z"));99 double h1 = ExecutionTracer.getValue(targetId);100 assertTrue(h1 > h0); //better101 assertTrue(h1 < 1);//but still no covered102 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));103 assertThrows(Exception.class, () -> te.parseLocalDate("1234-11-aa"));104 double h2 = ExecutionTracer.getValue(targetId);105 assertTrue(h2 > h1); //better106 assertTrue(h2 < 1);//but still no covered107 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));108 LocalDate date = te.parseLocalDate("1234-11-11");109 assertEquals(1234, date.getYear());110 double h3 = ExecutionTracer.getValue(targetId);111 assertTrue(h3 > h2); //better112 assertEquals(1, h3);//covered113 assertEquals(0, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));114 }115 @Test116 public void testDateAfter() throws Exception {117 TestabilityExc te = getInstance();118 SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy hh:mm a");119 Date dateInstance1 = sdf.parse("07/15/2016 11:00 AM");120 Date dateInstance2 = sdf.parse("07/15/2016 11:15 AM");121 te.after(dateInstance1, dateInstance2);122 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));123 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));124 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)125 .iterator().next();126 double h0 = ExecutionTracer.getValue(targetId);127 assertTrue(h0 > 0); //reached128 assertTrue(h0 < 1);//but no covered129 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));130 te.after(dateInstance1, dateInstance1);131 double h1 = ExecutionTracer.getValue(targetId);132 assertTrue(h1 > h0); //better133 assertTrue(h1 < 1);//but not covered134 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));135 te.after(dateInstance2, dateInstance1);136 double h2 = ExecutionTracer.getValue(targetId);137 assertTrue(h2 > h1); //better138 assertEquals(1, h2);//covered139 assertEquals(0, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));140 }141 @Test142 public void testDateBefore() throws Exception {143 TestabilityExc te = getInstance();144 SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy hh:mm a");145 Date dateInstance1 = sdf.parse("07/15/2016 11:00 AM");146 Date dateInstance2 = sdf.parse("07/15/2016 11:15 AM");147 te.before(dateInstance2, dateInstance1);148 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));149 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));150 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)151 .iterator().next();152 double h0 = ExecutionTracer.getValue(targetId);153 assertTrue(h0 > 0); //reached154 assertTrue(h0 < 1);//but no covered155 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));156 te.before(dateInstance1, dateInstance1);157 double h1 = ExecutionTracer.getValue(targetId);158 assertTrue(h1 > h0); //better159 assertTrue(h1 < 1);//but not covered160 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));161 te.before(dateInstance1, dateInstance2);162 double h2 = ExecutionTracer.getValue(targetId);163 assertTrue(h2 > h1); //better164 assertEquals(1, h2);//covered165 assertEquals(0, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));166 }167 @Test168 public void testDateEquals() throws Exception {169 TestabilityExc te = getInstance();170 SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy hh:mm a");171 Date dateInstance1 = sdf.parse("07/15/2016 11:00 AM");172 Date dateInstance2 = sdf.parse("07/15/2016 11:15 AM");173 Date dateInstance3 = sdf.parse("07/15/2016 11:30 AM");174 te.equals(dateInstance1, dateInstance3);175 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));176 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));177 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)178 .iterator().next();179 double h0 = ExecutionTracer.getValue(targetId);180 assertTrue(h0 > 0); //reached181 assertTrue(h0 < 1);//but no covered182 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));183 te.equals(dateInstance1, dateInstance2);184 double h1 = ExecutionTracer.getValue(targetId);185 assertTrue(h1 > h0); //better186 assertTrue(h1 < 1);//but not covered187 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));188 te.equals(dateInstance1, dateInstance1);189 double h2 = ExecutionTracer.getValue(targetId);190 assertTrue(h2 > h1); //better191 assertEquals(1, h2);//covered192 assertEquals(0, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));193 }194 @Test195 public void testCollectionsIsEmpty() throws Exception {196 TestabilityExc te = getInstance();197 List<String> nonSingletonNonEmptyList = Arrays.asList("One", "Two");198 te.isEmpty(nonSingletonNonEmptyList);199 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));200 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));201 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)202 .iterator().next();203 double h0 = ExecutionTracer.getValue(targetId);204 assertTrue(h0 > 0); //reached205 assertTrue(h0 < 1);//but no covered206 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));207 List<String> singletonList = Arrays.asList("One");208 te.isEmpty(singletonList);209 double h1 = ExecutionTracer.getValue(targetId);210 assertTrue(h1 > h0); //better211 assertTrue(h1 < 1);//but not covered212 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));213 List<String> emptyList = Collections.emptyList();214 te.isEmpty(emptyList);215 double h2 = ExecutionTracer.getValue(targetId);216 assertTrue(h2 > h1); //better217 assertEquals(1, h2);//covered218 assertEquals(0, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));219 }220 @Test221 public void testCollectionsContainsString() throws Exception {222 TestabilityExc te = getInstance();223 List<String> list0 = Arrays.asList("One", "Two", "Three");224 te.contains(list0, "O__");225 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));226 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));227 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)228 .iterator().next();229 double h0 = ExecutionTracer.getValue(targetId);230 assertTrue(h0 > 0); //reached231 assertTrue(h0 < 1);//but no covered232 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));233 te.contains(list0, "On_");234 double h1 = ExecutionTracer.getValue(targetId);235 assertTrue(h1 > h0); //better236 assertTrue(h1 < 1);//but not covered237 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));238 te.contains(list0, "One");239 double h2 = ExecutionTracer.getValue(targetId);240 assertTrue(h2 > h1); //better241 assertEquals(1, h2);//covered242 assertEquals(0, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));243 }244 @Test245 public void testCollectionsContainsInteger() throws Exception {246 TestabilityExc te = getInstance();247 List<Integer> list0 = Arrays.asList(10, 1000, 10000);248 te.contains(list0, 99);249 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));250 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));251 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)252 .iterator().next();253 double h0 = ExecutionTracer.getValue(targetId);254 assertTrue(h0 > 0); //reached255 assertTrue(h0 < 1);//but no covered256 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));257 te.contains(list0, 19);258 double h1 = ExecutionTracer.getValue(targetId);259 assertTrue(h1 > h0); //better260 assertTrue(h1 < 1);//but not covered261 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));262 te.contains(list0, 10);263 double h2 = ExecutionTracer.getValue(targetId);264 assertTrue(h2 > h1); //better265 assertEquals(1, h2);//covered266 assertEquals(0, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));267 }268 @Test269 public void testCollectionsContainsEmpty() throws Exception {270 TestabilityExc te = getInstance();271 List<Integer> list0 = Collections.emptyList();272 te.contains(list0, 99);273 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));274 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));275 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)276 .iterator().next();277 double h0 = ExecutionTracer.getValue(targetId);278 assertEquals(DistanceHelper.H_REACHED_BUT_EMPTY, h0); //not reached279 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));280 }281 @Test282 public void testCollectionsContainsNonHomogeneousList() throws Exception {283 TestabilityExc te = getInstance();284 List<Object> list0 = Arrays.asList(new Object(), "Hello", 100);285 te.contains(list0, 99);286 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));287 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));288 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)289 .iterator().next();290 double h0 = ExecutionTracer.getValue(targetId);291 assertTrue(h0 > 0); //reached292 assertTrue(h0 < 1);//but no covered293 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));294 }295 @Test296 public void testMapContainsStringKey() throws Exception {297 TestabilityExc te = getInstance();298 Map<String, Object> map0 = new HashMap<>();299 map0.put("One", null);300 map0.put("Two", null);301 map0.put("Three", null);302 te.containsKey(map0, "O__");303 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));304 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));305 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)306 .iterator().next();307 double h0 = ExecutionTracer.getValue(targetId);308 assertTrue(h0 > 0); //reached309 assertTrue(h0 < 1);//but no covered310 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));311 te.containsKey(map0, "On_");312 double h1 = ExecutionTracer.getValue(targetId);313 assertTrue(h1 > h0); //better314 assertTrue(h1 < 1);//but not covered315 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));316 te.containsKey(map0, "One");317 double h2 = ExecutionTracer.getValue(targetId);318 assertTrue(h2 > h1); //better319 assertEquals(1, h2);//covered320 assertEquals(0, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));321 }322 @Test323 public void testObjectEquals() throws Exception {324 TestabilityExc te = getInstance();325 te.objectEquals(null, null);326 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));327 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));328 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)329 .iterator().next();330 double h0 = ExecutionTracer.getValue(targetId);331 assertEquals(0, h0); // null value provides no gradient to reach false branch332 te.objectEquals("Hello!", null);333 double h1 = ExecutionTracer.getValue(targetId);334 assertEquals(1, h1); // false branch was covered335 }336 @Test337 public void testObjectEqualsNonNull() throws Exception {338 TestabilityExc te = getInstance();339 te.objectEquals("Hello!", null);340 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));341 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));342 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)343 .iterator().next();344 double h0 = ExecutionTracer.getValue(targetId);345 assertEquals(H_REACHED_BUT_NULL, h0); // null value provides no gradient to reach false branch346 te.objectEquals("Hello!", "Hell");347 double h1 = ExecutionTracer.getValue(targetId);348 assertTrue(h1 > 0); // true branch was reached349 assertTrue(h1 < 1); // true branch still not covered350 assertTrue(h1 > h0); // but we are doing better than before351 te.objectEquals("Hello!", "Hello!");352 double h2 = ExecutionTracer.getValue(targetId);353 assertEquals(1, h2); // true branch was covered354 }355 @Test356 public void testUnknownPatternDateFormatParse() throws Exception {357 TestabilityExc te = getInstance();358 SimpleDateFormat sdf = new SimpleDateFormat("YYYYMMdd HH:mm");359 assertThrows(Exception.class, () -> te.dateFormatParse(sdf, "07/"));360 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));361 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));362 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)363 .iterator().next();364 double h0 = ExecutionTracer.getValue(targetId);365 assertEquals(0, h0); // no guidance is provided since the pattern is unknown366 }367 @Test368 public void testDateFormatParse() throws Exception {369 TestabilityExc te = getInstance();370 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");371 assertThrows(Exception.class, () -> te.dateFormatParse(sdf, "1234-aa-aa"));372 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));373 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));374 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)375 .iterator().next();376 double h0 = ExecutionTracer.getValue(targetId);377 assertTrue(h0 > 0); // true branch was reached378 assertTrue(h0 < 1); // true branch still not covered379 assertThrows(Exception.class, () -> te.dateFormatParse(sdf, "1234-11-aa"));380 double h1 = ExecutionTracer.getValue(targetId);381 assertTrue(h1 > h0); // distance has improved382 assertTrue(h1 < 1); // but still the true branch is not covered383 assertThrows(Exception.class, () -> te.dateFormatParse(sdf, "1234-11-11"));384 double h2 = ExecutionTracer.getValue(targetId);385 assertTrue(h2 > h1); // true branch was reached386 assertTrue(h1 < 1); // true branch not covered387 te.dateFormatParse(sdf, "1234-11-11 11:11");388 double h3 = ExecutionTracer.getValue(targetId);389 assertEquals(1, h3); // true branch was covered390 }391 @Test392 public void testBooleanParse() throws Exception {393 TestabilityExc te = getInstance();394 te.parseBoolean(null);395 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));396 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));397 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)398 .iterator().next();399 double h0 = ExecutionTracer.getValue(targetId);400 assertEquals(H_REACHED_BUT_NULL, h0);401 te.parseBoolean("____");402 double h1 = ExecutionTracer.getValue(targetId);403 assertTrue(h1 > h0);404 assertTrue(h1 < 1);405 te.parseBoolean("T___");406 double h2 = ExecutionTracer.getValue(targetId);407 assertTrue(h2 > h1);408 assertTrue(h2 < 1);409 te.parseBoolean("T__E");410 double h3 = ExecutionTracer.getValue(targetId);411 assertTrue(h3 > h2);412 assertTrue(h3 < 1);413 te.parseBoolean("TruE");414 double h4 = ExecutionTracer.getValue(targetId);415 assertTrue(h4 > h3);416 assertEquals(1, h4);417 }418 @Test419 public void testLongParse() throws Exception {420 TestabilityExc te = getInstance();421 assertThrows(Exception.class, () -> te.parseLong(null));422 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));423 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));424 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)425 .iterator().next();426 double h0 = ExecutionTracer.getValue(targetId);427 assertEquals(H_REACHED_BUT_NULL, h0);428 assertThrows(Exception.class, () -> te.parseLong("-1___"));429 double h1 = ExecutionTracer.getValue(targetId);430 assertTrue(h1 > h0);431 assertTrue(h1 < 1);432 assertThrows(Exception.class, () -> te.parseLong("-10__"));433 double h2 = ExecutionTracer.getValue(targetId);434 assertTrue(h2 > h1);435 assertTrue(h2 < 1);436 assertThrows(Exception.class, () -> te.parseLong("-102_"));437 double h3 = ExecutionTracer.getValue(targetId);438 assertTrue(h3 > h2);439 assertTrue(h3 < 1);440 te.parseLong("-1023");441 double h4 = ExecutionTracer.getValue(targetId);442 assertTrue(h4 > h3);443 assertEquals(1, h4);444 }445 @Test446 public void testFloatParse() throws Exception {447 TestabilityExc te = getInstance();448 assertThrows(NullPointerException.class, () -> te.parseFloat(null));449 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));450 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));451 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)452 .iterator().next();453 double h0 = ExecutionTracer.getValue(targetId);454 assertEquals(H_REACHED_BUT_NULL, h0);455 assertThrows(NumberFormatException.class, () -> te.parseFloat("-1___"));456 double h1 = ExecutionTracer.getValue(targetId);457 assertTrue(h1 > h0);458 assertTrue(h1 < 1);459 assertThrows(NumberFormatException.class, () -> te.parseFloat("-10__"));460 double h2 = ExecutionTracer.getValue(targetId);461 assertTrue(h2 > h1);462 assertTrue(h2 < 1);463 assertThrows(NumberFormatException.class, () -> te.parseFloat("-10._"));464 double h3 = ExecutionTracer.getValue(targetId);465 assertTrue(h3 > h2);466 assertTrue(h3 < 1);467 te.parseFloat("-10.3");468 double h4 = ExecutionTracer.getValue(targetId);469 assertTrue(h4 > h3);470 assertEquals(1, h4);471 }472 @Test473 public void testLongMaxValueParse() throws Exception {474 TestabilityExc te = getInstance();475 assertThrows(Exception.class, () -> te.parseLong(null));476 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));477 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));478 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)479 .iterator().next();480 double h0 = ExecutionTracer.getValue(targetId);481 assertEquals(H_REACHED_BUT_NULL, h0);482 te.parseLong(Long.valueOf(Long.MIN_VALUE).toString());483 double h1 = ExecutionTracer.getValue(targetId);484 assertEquals(1, h1);485 }486 @Test487 public void testIntegerMaxValueParse() throws Exception {488 TestabilityExc te = getInstance();489 assertThrows(Exception.class, () -> te.parseInt(null));490 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));491 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));492 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)493 .iterator().next();494 double h0 = ExecutionTracer.getValue(targetId);495 assertEquals(H_REACHED_BUT_NULL, h0);496 te.parseInt(Integer.valueOf(Integer.MIN_VALUE).toString());497 double h1 = ExecutionTracer.getValue(targetId);498 assertEquals(1, h1);499 }500 @Test501 public void testFloatParseOfInteger() throws Exception {502 TestabilityExc te = getInstance();503 assertThrows(NullPointerException.class, () -> te.parseFloat(null));504 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));505 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));506 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)507 .iterator().next();508 double h0 = ExecutionTracer.getValue(targetId);509 assertEquals(H_REACHED_BUT_NULL, h0);510 te.parseFloat("-10000");511 double h1 = ExecutionTracer.getValue(targetId);512 assertTrue(h1 > h0);513 assertEquals(1, h1);514 }515 @Test516 public void testDoubleParseOfInteger() throws Exception {517 TestabilityExc te = getInstance();518 assertThrows(NullPointerException.class, () -> te.parseDouble(null));519 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));520 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));521 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)522 .iterator().next();523 double h0 = ExecutionTracer.getValue(targetId);524 assertEquals(H_REACHED_BUT_NULL, h0);525 te.parseDouble("-10000");526 double h1 = ExecutionTracer.getValue(targetId);527 assertTrue(h1 > h0);528 assertEquals(1, h1);529 }530 @Test531 public void testDoubleParse() throws Exception {532 TestabilityExc te = getInstance();533 assertThrows(NullPointerException.class, () -> te.parseDouble(null));534 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));535 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));536 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)537 .iterator().next();538 double h0 = ExecutionTracer.getValue(targetId);539 assertEquals(H_REACHED_BUT_NULL, h0);540 assertThrows(NumberFormatException.class, () -> te.parseDouble("-1___"));541 double h1 = ExecutionTracer.getValue(targetId);542 assertTrue(h1 > h0);543 assertTrue(h1 < 1);544 assertThrows(NumberFormatException.class, () -> te.parseDouble("-10__"));545 double h2 = ExecutionTracer.getValue(targetId);546 assertTrue(h2 > h1);547 assertTrue(h2 < 1);548 assertThrows(NumberFormatException.class, () -> te.parseDouble("-10._"));549 double h3 = ExecutionTracer.getValue(targetId);550 assertTrue(h3 > h2);551 assertTrue(h3 < 1);552 te.parseDouble("-10.3");553 double h4 = ExecutionTracer.getValue(targetId);554 assertTrue(h4 > h3);555 assertEquals(1, h4);556 }557 @Test558 public void testStringEquals() throws Exception {559 TestabilityExc te = getInstance();560 te.stringEquals("Hello", null);561 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));562 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));563 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)564 .iterator().next();565 double h0 = ExecutionTracer.getValue(targetId);566 assertEquals(0, h0);567 te.stringEquals("Hello", "H");568 double h1 = ExecutionTracer.getValue(targetId);569 assertTrue(h1 > h0);570 assertTrue(h1 < 1);571 te.stringEquals("Hello", "He");572 double h2 = ExecutionTracer.getValue(targetId);573 assertTrue(h2 > h1);574 assertTrue(h2 < 1);575 te.stringEquals("Hello", "Hell");576 double h3 = ExecutionTracer.getValue(targetId);577 assertTrue(h3 > h2);578 assertTrue(h3 < 1);579 te.stringEquals("Hello", "Hello");580 double h4 = ExecutionTracer.getValue(targetId);581 assertEquals(1, h4);582 }583 @Test584 public void testStringEqualsIgnoreCase() throws Exception {585 TestabilityExc te = getInstance();586 te.stringEqualsIgnoreCase("hello", null);587 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));588 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));589 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)590 .iterator().next();591 double h0 = ExecutionTracer.getValue(targetId);592 assertEquals(0, h0);593 te.stringEqualsIgnoreCase("hello", "H");594 double h1 = ExecutionTracer.getValue(targetId);595 assertTrue(h1 > h0);596 assertTrue(h1 < 1);597 te.stringEqualsIgnoreCase("HeLLo", "He");598 double h2 = ExecutionTracer.getValue(targetId);599 assertTrue(h2 > h1);600 assertTrue(h2 < 1);601 te.stringEqualsIgnoreCase("HEllO", "Hell");602 double h3 = ExecutionTracer.getValue(targetId);603 assertTrue(h3 > h2);604 assertTrue(h3 < 1);605 te.stringEqualsIgnoreCase("HeLLo", "hello");606 double h4 = ExecutionTracer.getValue(targetId);607 assertEquals(1, h4);608 }609 @Test610 public void testStringIsEmpty() throws Exception {611 TestabilityExc te = getInstance();612 te.stringIsEmpty("OneTwo");613 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));614 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));615 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)616 .iterator().next();617 double h0 = ExecutionTracer.getValue(targetId);618 assertTrue(h0 > 0); //reached619 assertTrue(h0 < 1);//but no covered620 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));621 te.stringIsEmpty("One");622 double h1 = ExecutionTracer.getValue(targetId);623 assertTrue(h1 > h0); //better624 assertTrue(h1 < 1);//but not covered625 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));626 te.stringIsEmpty("");627 double h2 = ExecutionTracer.getValue(targetId);628 assertTrue(h2 > h1); //better629 assertEquals(1, h2);//covered630 assertEquals(0, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));631 }632 @Test633 public void testStringContentEquals() throws Exception {634 TestabilityExc te = getInstance();635 assertThrows(NullPointerException.class, () -> te.stringContentEquals("Hello", null));636 assertEquals(0, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));637 te.stringContentEquals("Hello", "H");638 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));639 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));640 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)641 .iterator().next();642 double h0 = ExecutionTracer.getValue(targetId);643 assertTrue(h0 > 0);644 assertTrue(h0 < 1);645 te.stringContentEquals("Hello", "He");646 double h1 = ExecutionTracer.getValue(targetId);647 assertTrue(h1 > h0);648 assertTrue(h1 < 1);649 te.stringContentEquals("Hello", "Hel");650 double h2 = ExecutionTracer.getValue(targetId);651 assertTrue(h2 > h1);652 assertTrue(h2 < 1);653 te.stringContentEquals("Hello", "Hell");654 double h3 = ExecutionTracer.getValue(targetId);655 assertTrue(h3 > h2);656 assertTrue(h3 < 1);657 te.stringContentEquals("Hello", "Hello");658 double h4 = ExecutionTracer.getValue(targetId);659 assertEquals(1, h4);660 }661 @Test662 public void testStringContentEqualsStringBuffer() throws Exception {663 TestabilityExc te = getInstance();664 assertThrows(NullPointerException.class, () -> te.stringContentEquals("Hello", (StringBuffer) null));665 assertEquals(0, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));666 te.stringContentEquals("Hello", new StringBuffer("H"));667 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));668 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));669 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)670 .iterator().next();671 double h0 = ExecutionTracer.getValue(targetId);672 assertTrue(h0 > 0);673 assertTrue(h0 < 1);674 te.stringContentEquals("Hello", new StringBuffer("He"));675 double h1 = ExecutionTracer.getValue(targetId);676 assertTrue(h1 > h0);677 assertTrue(h1 < 1);678 te.stringContentEquals("Hello", new StringBuffer("Hel"));679 double h2 = ExecutionTracer.getValue(targetId);680 assertTrue(h2 > h1);681 assertTrue(h2 < 1);682 te.stringContentEquals("Hello", new StringBuffer("Hell"));683 double h3 = ExecutionTracer.getValue(targetId);684 assertTrue(h3 > h2);685 assertTrue(h3 < 1);686 te.stringContentEquals("Hello", new StringBuffer("Hello"));687 double h4 = ExecutionTracer.getValue(targetId);688 assertEquals(1, h4);689 }690 @Test691 public void testStringContains() throws Exception {692 TestabilityExc te = getInstance();693 assertThrows(NullPointerException.class, () -> te.contains("Hello", null));694 assertEquals(0, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));695 te.contains("Hello World", "_____");696 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));697 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));698 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)699 .iterator().next();700 double h0 = ExecutionTracer.getValue(targetId);701 assertTrue(h0 > 0);702 assertTrue(h0 < 1);703 te.contains("Hello World", "W____");704 double h1 = ExecutionTracer.getValue(targetId);705 assertTrue(h1 > h0);706 assertTrue(h1 < 1);707 te.contains("Hello World", "Wo___");708 double h2 = ExecutionTracer.getValue(targetId);709 assertTrue(h2 > h1);710 assertTrue(h2 < 1);711 te.contains("Hello World", "Wor__");712 double h3 = ExecutionTracer.getValue(targetId);713 assertTrue(h3 > h2);714 assertTrue(h3 < 1);715 te.contains("Hello World", "Worl_");716 double h4 = ExecutionTracer.getValue(targetId);717 assertTrue(h4 > h3);718 assertTrue(h4 < 1);719 te.contains("Hello World", "World");720 double h5 = ExecutionTracer.getValue(targetId);721 assertEquals(1, h5);722 }723 @Test724 public void testStartsWith() throws Exception {725 TestabilityExc te = getInstance();726 assertThrows(NullPointerException.class, () -> te.startsWith("Hello", null));727 assertEquals(0, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));728 te.startsWith("Hello World", "_____");729 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));730 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));731 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)732 .iterator().next();733 double h0 = ExecutionTracer.getValue(targetId);734 assertTrue(h0 > 0);735 assertTrue(h0 < 1);736 te.startsWith("Hello World", "H____");737 double h1 = ExecutionTracer.getValue(targetId);738 assertTrue(h1 > h0);739 assertTrue(h1 < 1);740 te.startsWith("Hello World", "He___");741 double h2 = ExecutionTracer.getValue(targetId);742 assertTrue(h2 > h1);743 assertTrue(h2 < 1);744 te.startsWith("Hello World", "Hel__");745 double h3 = ExecutionTracer.getValue(targetId);746 assertTrue(h3 > h2);747 assertTrue(h3 < 1);748 te.startsWith("Hello World", "Hell_");749 double h4 = ExecutionTracer.getValue(targetId);750 assertTrue(h4 > h3);751 assertTrue(h4 < 1);752 te.startsWith("Hello World", "Hello");753 double h5 = ExecutionTracer.getValue(targetId);754 assertEquals(1, h5);755 }756 @Test757 public void testStartsWithOffSet() throws Exception {758 TestabilityExc te = getInstance();759 assertThrows(NullPointerException.class, () -> te.startsWith("Hello", null, 0));760 assertEquals(0, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));761 te.startsWith("Hello World", "_____", 0);762 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));763 assertEquals(1, ExecutionTracer.getNumberOfNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT));764 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)765 .iterator().next();766 double h0 = ExecutionTracer.getValue(targetId);767 assertTrue(h0 > 0);768 assertTrue(h0 < 1);769 te.startsWith("Hello World", "H____", 0);770 double h1 = ExecutionTracer.getValue(targetId);771 assertTrue(h1 > h0);772 assertTrue(h1 < 1);773 te.startsWith("Hello World", "He___", 0);774 double h2 = ExecutionTracer.getValue(targetId);775 assertTrue(h2 > h1);776 assertTrue(h2 < 1);777 te.startsWith("Hello World", "Hel__", 0);778 double h3 = ExecutionTracer.getValue(targetId);779 assertTrue(h3 > h2);780 assertTrue(h3 < 1);781 te.startsWith("Hello World", "Hell_", 0);782 double h4 = ExecutionTracer.getValue(targetId);783 assertTrue(h4 > h3);784 assertTrue(h4 < 1);785 te.startsWith("Hello World", "Hello", 0);786 double h5 = ExecutionTracer.getValue(targetId);787 assertEquals(1, h5);788 }789 @Test790 public void testMatcherMatches() throws Exception {791 TestabilityExc te = getInstance();792 te.matcherMatches(Pattern.compile("_____").matcher("Hello"));793 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));794 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)795 .iterator().next();796 double h0 = ExecutionTracer.getValue(targetId);797 assertTrue(h0 > 0);798 assertTrue(h0 < 1);799 te.matcherMatches(Pattern.compile("H_l__").matcher("Hello"));800 double h1 = ExecutionTracer.getValue(targetId);801 assertTrue(h1 > h0);802 assertTrue(h1 < 1);803 te.matcherMatches(Pattern.compile("Hello").matcher("Hello"));804 double h2 = ExecutionTracer.getValue(targetId);805 assertEquals(1, h2);806 }807 @Test808 public void testPatternMatches() throws Exception {809 TestabilityExc te = getInstance();810 te.patternMatches("Hello", "_____");811 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));812 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)813 .iterator().next();814 double h0 = ExecutionTracer.getValue(targetId);815 assertTrue(h0 > 0);816 assertTrue(h0 < 1);817 te.patternMatches("Hello", "H_l__");818 double h1 = ExecutionTracer.getValue(targetId);819 assertTrue(h1 > h0);820 assertTrue(h1 < 1);821 te.patternMatches("Hello", "Hello");822 double h2 = ExecutionTracer.getValue(targetId);823 assertEquals(1, h2);824 }825 @Test826 public void testNullPatternMatches() throws Exception {827 TestabilityExc te = getInstance();828 assertThrows(NullPointerException.class, () -> te.patternMatches(null, "___"));829 assertThrows(NullPointerException.class, () -> te.patternMatches("Hello", null));830 assertThrows(NullPointerException.class, () -> te.patternMatches(null, null));831 }832 @Test833 public void testStringMatches() throws Exception {834 TestabilityExc te = getInstance();835 te.stringMatches("Hello", "_____");836 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));837 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)838 .iterator().next();839 double h0 = ExecutionTracer.getValue(targetId);840 assertTrue(h0 > 0);841 assertTrue(h0 < 1);842 te.stringMatches("Hello", "H_l__");843 double h1 = ExecutionTracer.getValue(targetId);844 assertTrue(h1 > h0);845 assertTrue(h1 < 1);846 te.stringMatches("Hello", "Hello");847 double h2 = ExecutionTracer.getValue(targetId);848 assertEquals(1, h2);849 }850 @Test851 public void testMatcherFind() throws Exception {852 TestabilityExc te = getInstance();853 Matcher matcher = Pattern.compile("Hello").matcher("Hello Hello");854 assertTrue(matcher.find());855 assertEquals(5, matcher.end());856 assertEquals(5, matcher.end());857 assertTrue(matcher.find());858 assertEquals(11, matcher.end());859 assertEquals(11, matcher.end());860 assertFalse(matcher.find());861 assertThrows(IllegalStateException.class, () -> matcher.end());862 matcher.reset();863 assertTrue(matcher.find());864 assertEquals(5, matcher.end());865 assertEquals(5, matcher.end());866 assertTrue(matcher.find());867 assertEquals(11, matcher.end());868 assertEquals(11, matcher.end());869 assertFalse(matcher.find());870 assertThrows(IllegalStateException.class, () -> matcher.end());871 matcher.reset();872 // first match873 boolean find0 = te.matcherFind(matcher);874 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));875 assertEquals(true, find0);876 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)877 .iterator().next();878 double h0 = ExecutionTracer.getValue(targetId); // false branch not covered879 assertEquals(0, h0);880 // second match881 boolean find1 = te.matcherFind(matcher);882 assertEquals(true, find1);883 double h1 = ExecutionTracer.getValue(targetId);884 assertTrue(h0 == h1);885 // no match886 te.matcherFind(matcher);887 double h2 = ExecutionTracer.getValue(targetId);888 assertEquals(1, h2);889 }890 @Test891 public void testMatcherNotFind() throws Exception {892 TestabilityExc te = getInstance();893 assertFalse(te.matcherFind(Pattern.compile("World").matcher("Hello W___d")));894 assertEquals(2, ExecutionTracer.getNumberOfObjectives(ObjectiveNaming.METHOD_REPLACEMENT));895 String targetId = ExecutionTracer.getNonCoveredObjectives(ObjectiveNaming.METHOD_REPLACEMENT)896 .iterator().next(); // true branch897 double h0 = ExecutionTracer.getValue(targetId);898 assertTrue(h0 > 0);899 assertTrue(h0 < 1);900 assertFalse(te.matcherFind(Pattern.compile("World").matcher("Hello W_r_d")));901 double h1 = ExecutionTracer.getValue(targetId);902 assertTrue(h1 > h0);903 assertTrue(h1 < 1);904 assertFalse(te.matcherFind(Pattern.compile("World").matcher("Hello W_rld")));905 double h2 = ExecutionTracer.getValue(targetId);906 assertTrue(h2 > h1);...

Full Screen

Full Screen

getInstance

Using AI Code Generation

copy

Full Screen

1public class TestabilityExc{2 public int method1(int a, int b) throws Exception {3 if(a > 0 && b > 0){4 return a + b;5 } else {6 throw new Exception("a or b is negative");7 }8 }9}10public class TestabilityExcInstrumentedTest{11 public static TestabilityExc getInstance(){12 return new TestabilityExc();13 }14}15public class TestabilityExcTest{16 public void testMethod1(){17 TestabilityExc instance = TestabilityExcInstrumentedTest.getInstance();18 try{19 int result = instance.method1(1, 2);20 Assert.assertEquals(3, result);21 } catch (Exception e){22 Assert.fail(e.getMessage());23 }24 }25}26public class TestabilityExcTest{27 public void testMethod1(){28 TestabilityExc instance = TestabilityExcInstrumentedTest.getInstance();29 try{30 int result = instance.method1(1, 2);31 Assert.assertEquals(3, result);32 } catch (Exception e){33 Assert.fail(e.getMessage());34 }35 }36}37public class TestabilityExcTest{38 public void testMethod1(){39 TestabilityExc instance = TestabilityExcInstrumentedTest.getInstance();40 try{41 int result = instance.method1(1, 2);42 Assert.assertEquals(3, result);43 } catch (Exception e){44 Assert.fail(e.getMessage());45 }46 }47}

Full Screen

Full Screen

getInstance

Using AI Code Generation

copy

Full Screen

1org.evomaster.client.java.instrumentation.example.methodreplacement.TestabilityExc var0 = org.evomaster.client.java.instrumentation.example.methodreplacement.TestabilityExcInstrumentedTest.getInstance();2var0.method1();3org.evomaster.client.java.instrumentation.example.methodreplacement.TestabilityExc var1 = org.evomaster.client.java.instrumentation.example.methodreplacement.TestabilityExcInstrumentedTest.getInstance();4var1.method1();5org.evomaster.client.java.instrumentation.example.methodreplacement.TestabilityExc var2 = org.evomaster.client.java.instrumentation.example.methodreplacement.TestabilityExcInstrumentedTest.getInstance();6var2.method1();

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful